Loops/While: Difference between revisions

→‎{{header|MATLAB}}: add vectorized code, works fine with Octave, too.
(Add LabVIEW)
(→‎{{header|MATLAB}}: add vectorized code, works fine with Octave, too.)
Line 481:
]</lang>
 
=={{header|MATLAB}} / {{header|Octave}}==
In Matlab (like Octave) the math is done floating point, then rounding to integer, so that 1/2 will be always 1 and never 0. A 'floor' is used to round the number.
<lang Matlab>i = 1024;
Line 488:
i = floor(i/2);
end</lang>
 
A vectorized version of the code is
 
<lang Matlab> printf('%d\n', 2.^[log2(1024):-1:0]); </lang>
 
=={{header|MAXScript}}==
Anonymous user