The for Loop
Syntax
The syntax of a for loop in MATLAB is:
for index = values
<program statements>
...
end
values has one of the following forms:
initval:endval - increments the index variable from initval to endval by 1, and repeats execution of program statements until index is greater than endval.
initval:step:endval - increments index by the value step on each iteration, or decrements when step is negative.
valArray - creates a column vector index from subsequent columns of arrayvalArray on each iteration. For example, on the first iteration, index = valArray(:,1). The loop executes for a maximum of n times, where n is the number of columns of valArray, given by numel(valArray, 1, :). The input valArray can be of any MATLAB data type, including a string, cell array, or struct.
No comments:
Post a Comment