BMES 546 Lecture 9: BMES 546 - Advanced Functions
Document Summary
Functions without making a function file funchandle = @ (arguments) functionbody; Ex. circlearea = @(radius) pi*radius^2; circlearea(4) ans = 50. 2655 str2func converts a string to a function handle. Common issues due to shared workspace, so variables change and if a variable is reused in a subfunction, it will be the old values. Persistent variables are in a function that continues to stay even after the function is done executing. If you are defining the variable in the function (count =0) then it will keep doing that unless you have it conditionally happen only the first time you have the function. Ex. if isempty(count) count=0 end dir function takes out the directory info on a file. Store it into a variable to have the variable become a structure and pull out certain information. Ex. a=dir(filename) a. datenum (this will pull up information of the date/time that the file was created/modified.