{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lecture36 - Lecture 36 MATLAB Mandelbrot Engineering 101...

This preview shows pages 1–11. Sign up to view the full content.

Engineering 101 Engineering 101 Lecture 36 Lecture 36 MATLAB Mandelbrot MATLAB Mandelbrot Prof. Michael Falk University of Michigan, College of Engineering

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Announcements Announcements Project 8, Due Wednesday at 9pm Also on paper in your lab section Thurs/Fri. Samples of Exam 4 have now been posted Exam 4 will take place Fri, Dec 15 from 8-10am. Location to be announced. If you have a conflict with this time contact me by this Friday. The alternate exam time for those with exam conflicts only is Fri, Dec 15 from 10:30-12:30
More Announcements More Announcements Wednesday: Final MATLAB lecture Friday: Exam 4 Review Monday: Super Quiz Project 8 clarification: If a colony has 2 or more neighbors with the same, highest value of fitness that are of different types, the colony does not change .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Default Arguments in Functions Default Arguments in Functions You may have noticed that some of the bulit-in MATLAB functions can accept and return different numbers of arguments. This is handled by using the values nargin and nargout .
nargin/nargout nargin/nargout nargin is equal to the number of input arguments passed into the function. nargout is equal to the number of output arguments requested from the function.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Using nargin Using nargin Let’s say I want to have a procedure that has some default arguments if none is specified. function val = simulate(time, startval) val = zeros(time); if nargin<2 | isempty(startval) val(1) = 0; else val(1) = startval; end for t = 2:time val(t) = onestep(val(t-1)); end
Using nargin Using nargin Equivalently: function val = simulate(time, startval) val = zeros(time); if nargin<2 | isempty(startval), startval = 0; end val(1) = startval; for t = 2:time val(t) = onestep(val(t-1)); end

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Using nargout Using nargout function [m,v]=MeanVar(X) % MeanVar Computes the mean and variance n=size(X,1); m=mean(X); if nargout>1 temp=X-m(ones(n,1),:); v=sum(temp.*temp)/(n-1); end
Exercise 1 Exercise 1 Which function will take in up to 3 matrices and return the average of these matrices?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Exercise 1 Exercise 1 3.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}