Recently Posted




Notice: SSI.php was unable to load a session! This may cause problems with logout and other functions - please make sure SSI.php is included before *anything* else in all your scripts! in /home/tutorial/public_html/mathforum/SSI.php on line 155

Archive for the ‘Controls’ Category


while

while Repeat statements an indefinite number of times.
The general form of a statement is:

while expression
statements
END

The statements are executed the real part of the expression
has all non-zero elements. The expression is usually the result of
expr rop expr where rop is ==, <, >, <=, >=, or ~=.

The BREAK statement can be used to terminate the loop prematurely.

For example (assuming A already defined):

View CodeMATLAB
1
2
3
4
5
6
E = 0*A; F = E + eye(size(E)); N = 1;
 norm(E+F-E,1) &gt; 0,
E = E + F;
F = A*F/N;
N = N + 1;
end

See also for, if, switch, break, end.

Tags: ,

return

return to invoking function.
causes a to the invoking function or to the keyboard.
It also terminates the KEYBOARD mode.

Normally functions when the end of the function is reached.
A statement can be used to force an early .

Example

View CodeMATLAB
1
2
3
4
5
6
7
function d = det(A)
if isempty(A)
d = 1;

else
...
end

See also function, keyboard.

Tags: ,

elseif

IF statement condition.
is used with IF. The statements after the are
executed if the expression is true and all the preceding IF and
expressions are false. An expression is considered true if
the real part has all non-zero elements.

does not need a matching END, while ELSE IF does.

The general form of the IF statement is
IF expression
statements
expression
statements
ELSE
statements
END

See also if, else, end.

Tags: ,