MATLAB: Indices on the left side are not compatible with the size of the right side error

errormatrixmatrix array

So I'm writing code to create a matrix, M that stores various values for theta and x, but i'm unsure as to what to do about the error. Please let me know what I need to correct in order to overcome the error.
M=[];
theta=linspace(0,180,401);
x=linspace(0,10,501);
for i_theta = 1:length(theta)
for i_x = 1:length(x)
M(i_x,i_theta)= 1200*sind(theta(i_theta)) +400*cosd(theta)*x(i_x);
end
end
****************************************************************************
Unable to perform assignment because the indices on the left side are not compatible with the
size of the right side.
Error in Lab7 (line 9)
M(i_x,i_theta)= 1200*sind(theta(i_theta)) +400*cosd(theta)*x(i_x);

Best Answer

It's a typo in this line
M(i_x,i_theta)= 1200*sind(theta(i_theta)) +400*cosd(theta)*x(i_x);
I think it should be
M(i_x,i_theta)= 1200*sind(theta(i_theta)) +400*cosd(theta(i_theta))*x(i_x);