The for loop doesn't iterate

后端 未结 2 978
说谎
说谎 2021-01-12 12:41

In MATLAB the following for loop:

for i = [1:100]\' 
    %\'// Do something, such as disp(i)
end

isn\'t apparently really impl

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-12 13:16

    This is not correct. The code:

    for i=1:100
        disp(i)
    end
    

    will print all the values 1 through 100 consecutively. While Matlab does encourage vectorization, you can definitely use traditional loops with the style of coding you used above.

提交回复
热议问题