MATLAB: For loop, Subscript indices must either be real positive integers or logicals

error messagefor loop

Hi,
I have been trying the following commands, but I could not, and got that error, (I got that error, Subscript indices must either be real positive integers or logicals.),
for i=[90,30,-30]
theta(i)=i*pi/180
end
& also, when type length of (i) it equals =-30, how ?, and I have 3 variables ?
actually, I hope to have 3 variables (one at i =90, and another =30, and so on ]
So please could you tell me how could I do this ?
Thanks,

Best Answer

https://www.mathworks.com/matlabcentral/answers/470959-loop-with-two-variables#answer_382585 shows a general structure you can use for looping with values that are not small consecutive integers.