Matlab Tutorial 7 – If statement
There are times when you would like your algorithm/code to make a decision, and the “if” statement is the way to do it. The general syntax in MATLAB is as follows :
if relation
statement(s)
elseif relation % if applicable
statement(s) % if applicable
else % if applicable
statement(s)
% if applicable
end
The logical operators (&, |, ~) could also be used to create more complex relations.
Let us illustrate the “if” statement through a simple example. Suppose we would like to define and plot the piecewise defined function
Read more...
Matlab Tutorial 7 – If statement