MATLAB: Create matrix using nested loops

for loopmatrix manipulation

Hi everyone, I would like to create a 2×5 matrix. Row 1 will be the sin(x) and Row 2 the cos(x). Each column will be the values of x being 0, 90, 180, 270, 360.
I do not seem to get it right. Can anyone please direct me to my mistake? I do not need a solution to my assignment, I just need some guidance.
for j=0:4
j=j+1
for i=0:90:360
Y(1,j)=sin(i)
Y(2,j)=cos(i)
end
end
Any help is appreciated.

Best Answer

Theta=[0, 90, 180, 270, 360];
Y=zeros(2,numel(Theta))
Y(1,:)=sind(Theta);
Y(2,:)=cosd(Theta);
NOTE the "d" after sin and cos function.