Aaron's Octave Assignment: Difference between revisions
Jump to navigation
Jump to search
Aaron.boyd (talk | contribs) (Created page with 'Just like C++ Octave and Matlab recognize if statements. if (%your condition%) %your command%; else %your command%; end More complex systems can use the elseif command i…') |
Aaron.boyd (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
Just like C++ Octave and Matlab recognize if statements. |
Just like C++ Octave and Matlab recognize if statements. |
||
if (%your condition%) |
if (%your condition%) |
||
%your command%; |
|||
else |
else |
||
%your command%; |
|||
end |
end |
||
More complex systems can use the elseif command |
More complex systems can use the elseif command |
||
if (%condition%) |
if (%condition%) |
||
elseif (%condition%) |
elseif (%condition%) |
||
%commands%; |
%commands%; |
||
elseif(%condition%) |
elseif(%condition%) |
||
%commands%; |
%commands%; |
||
else(%condition%) |
else(%condition%) |
||
%commands%; |
%commands%; |
||
end |
end |
||
for instance |
for instance |
||
if (a=b) |
if (a=b) |
||
t = -1; |
t = -1; |
||
elseif (a>b) |
elseif (a>b) |
||
t = -2; |
t = -2; |
||
else |
else |
||
t = 0; |
t = 0; |
||
end |
end |
Latest revision as of 09:37, 4 October 2010
Just like C++ Octave and Matlab recognize if statements.
if (%your condition%) %your command%; else %your command%; end
More complex systems can use the elseif command
if (%condition%) elseif (%condition%) %commands%; elseif(%condition%) %commands%; else(%condition%) %commands%; end
for instance
if (a=b) t = -1; elseif (a>b) t = -2; else t = 0; end