To cancel a command: Ctrl C
if ... else ...
if expression
statement
else if expression
statement
else
statement
end
end
Note:
1. The brackets () are not needed around the expression
2. The block of statement does not need to be delimited by the braces {}
3. The end command is used to mark the end of the script statement.
switch selection
switch x
case x1
statements
case x2
statements
otherwise
statements
end
or, similarly
switch x
case x1, statements
case x2, statements
otherwise, statements
end
for loops
for variable = vector
statements
end
Ex:
for n=1:5
nf(n) = factorial(n);
end
disp(nf)
while loops
while expression
statements
end
Sunday, October 7, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment