


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
A lecture note from a university course on functions and program development. It covers the concept of functions as pre-defined or user-defined blocks of code, their syntax, and usage in matlab. The lecture also discusses the benefits of using functions and provides examples of simple functions and their usage. The document also mentions the upcoming topics in the course, which include numerical analysis and signal processing.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



% Example of Conditional Code Block x=3, y=0, z=10; if x==y % use == to compare for equivalence y = z; x = x^2;
elseif x < y % otherwise, if x is less than y... y = x+1; else % if previous statements are false... y = x^2; x = z; end % terminate code block
function [x, y, z] = computeThis1(x, y, z) % a simple function that takes 3 input values, % and returns the same 3 values that may or may not have been updated in %the function body if x==y %use == to compare for equivalence y = z x = x^2; elseif x < y %less than y = x+1; else %if previous statements are false... y = x^2; x = z; end % terminate code block end % terminate parent function
%define three variables a=4, b=3, c=7; %call function that takes 3 variables and returns 3 variables. [d, e, f] = computeThis1(a, b, c);
function [x, y, z] = computeThis2(x, y, z) % a simple function that takes 3 input values, % and returns the same 3 values that may or may not have been updated in %the function body. This is the parent/primary function. if x==y %use == to compare for equivalence