How to form a for loop which performs descending order in Scilab -
i trying perform descend loop in scilab like:
for i=7: 1 disp(i); end
but apparently didn't work , there no errors too.
is possible? , if yes, how it?
syntax
as for-loop documentation states, loop's syntax is:
for variable=expression instruction, ,instruction,end
if expression
matrix or row vector, variable
takes values values of each column of matrix.
your example
your for-loop uses 7:1 expression
, result in valid empty vector:
-->7:1 ans = []
the for-loop takes each value in vector , finishes, since vector empty finishes directly. valid syntax.
working example
the documentation gives following example of working decreasing loop:
for j=4:-1:1 disp(j); end // decreasing loop
Comments
Post a Comment