

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Outline Mar 16 Material Type: Notes; Professor: Sawicki; Class: Computer Methods in Biomedical Engineering; Subject: Biomedical Engineering; University: North Carolina State University; Term: Spring 2011;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Lecture 16: Wednesday March 16, 2011: Announcements: SH6 is due today. SL5 is due tomorrow - Thursday March 17th. Happy St. Patty’s Day! Case 3 is due Monday March 21st. Please take advantage of Prof. Sawicki’s Office Hours on M’s and T’s from 4-5PM 4212C EB3 or by appt. Ben’s hours are still being held Thursday afternoons. You can pick up your graded exam after lab on Thursday 17th. Questions on grading please see Prof. Sawicki. SH7 will be up early next week. Case 4 will be up late next week. Exam 2 is scheduled for Wednesday, April 6th^ in-class. Reading for Next Time: -Function Functions Palm p124-129 (i.e. fzero, fminbnd, fminsearch, and fsolve) + Function Handles (p 124) -Debugging Palm Chapter 4.8. -Ch 9.1 and 9.2 more on Numerical Differentiation and Integration. -After that start looking at Ch. 8 on Linear Algebraic Equations. *SH EC: Work the Torus problem from SH6 on the board. *Today’s Goals:
diary LectureMar16.m *II. Numerical Derivative: Two Methods DIFF Difference and approximate derivative. DIFF(X), for a vector X, is [X(2)-X(1) X(3)-X(2) ... X(n)-X(n-1)]. GRADIENT Approximate gradient. [FX,FY] = GRADIENT(F) returns the numerical gradient of the matrix F. FX corresponds to dF/dx, the differences in x (horizontal) direction. FY corresponds to dF/dy, the differences in y (vertical) direction. The spacing between points in each direction is assumed to be one. When F is a vector, DF = GRADIENT(F)is the 1-D gradient. *III. More on Functions –
Anonymous Functions: (Palm Ch 3. pg. 132-133) Anonymous functions provide a quick, in-line method of defining and executing a function without having it in a separate m-file. This is useful for simple expressions like, exponential equations or polynomial equations. Syntax is as follows: function handle = @(argument list) expression The function handle (i.e. reference) is just the name of your function. The argument list can be as long as you like, or even empty (see Palm page 133). The expression can only be a single executable MATLAB expresion. To call/execute the anonymous function: output variable name= function handle(argument list) For example, to define an anonymous function called sq that can compute the square of any input value x --> %Example of an anonymous function with one input %function handle = @(input argument(s)) function expression sq = @(x) x.^2; %This defines a function sq that computes the %square of the input value x (which can be an array - note %element wise definition) %Then, a bunch of ways to call it- y= sq(5) z= sq([5 6 8]) a=6, b=12, c=13; h=[a b c]; t=sq(h) Anonymous functions can be defined with multiple inputs. For example --> %Example of an anonymous function with two inputs sumsqrt= @(x,y) sqrt(x.^2 + y.^2); % This defines the function %sumsqrt % To call it: y= sumsqrt(4,5) Anonymous functions can call each other (Palm p. 133). For example -->