| MATLAB Function Reference | ![]() |
Syntax
forvariable=expressionstatementsend
Description
forvariable = expressionstatement...statementend
expression 在每次程式執行到 end時都會執行並儲存到variable中。
實際上, expression 都是scalar : scalar
的格式,scalar 都是單一數字( its columns are simply scalars.)
Examples
設已經設定 n 為一個數值。產生 Hilbert matrix,並利用 zeros
來預先分配此矩陣到保存記憶體(conserve memory):
a = zeros(n,n) % Preallocate matrix
for i = 1:n
for j = 1:n
a(i,j) = 1/(i+j -1);
end
end
for s = 1.0: -0.1: 0.0,...,end
for e = eye(n),...,end
for V = A,...,end
for j = 1:n,V = A(:,j);...,end
See Also
break, end, if, return, switch, while
The colon operator :
| fopen (serial) | format | ![]() |