Matlab Octave Control Elements: Difference between revisions
Jump to navigation
Jump to search
(→if) |
|||
Line 43: | Line 43: | ||
<''statement''> | <''statement''> | ||
endif; | endif; | ||
==Conditions== | |||
===Equality=== |
Latest revision as of 21:20, 11 February 2018
Internal
Loops
For all loops, 'break' and 'continue' work:
for
for i = <range> <statement> end;
for i = 1:10 disp(i) end;
The range can be a vector:
v = [2 4 6 8] for i = v disp(i) end;
while
i = 1; while i <= 5; i = i + 1; end;
if
if <condition> <statement> endif;
if <condition> <statement> else <statement> endif;
if <condition> <statement> elseif <condition> <statement> ... else <statement> endif;