MATLAB: How to store the individul iterations of a loop in a matrix

loops

Here is my code:
for i=(1:1:6)
s=sind(60*(i));
c=cosd(60*i)
end
what I want to get from this are two matrices, where the values of sine and cosine are displayed for each value of i. Is there a way to do this?

Best Answer

Index your variables:
s(i) = sind(60*(i));
c(i) = cosd(60*i);
Or just eliminate the loop altogether:
x = (1:1:6);
s = sind(60*x);
c = cosd(60*x);
Related Question