


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
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