Matlab for loop that manipulates a list? -
Matlab for loop that manipulates a list? -
i new matlab apologize relatively easy questions.
i have:
for i=0:10 values(:,1) = (2.*i-20)*5.; end i want script produce vector of 11 values have been changed (2.*i-20)*5. each i.
i think meant this:
for i=0:10 values(i+1,1) = (2.*i-20)*5.; %you can write -> values(i) end more general way fill array in for loop when loop variable doesn't go 1 desired value:
count=0; i=0:10 count=count+1; values(count,1) = (2.*i-20)*5.; end but wait, not @ way of programming in matlab. should such operations follows:
i=0:10; values=(2.*i-20)*5.; the above solution called vectorized solution.
matlab loops for-loop vectorization
Comments
Post a Comment