MATLAB: Subscripted assignment dimension mismatch. what does it mean

please solve the problem

clc;
clear;
close all;
k=3;
for i=1:k
fi= input('\nEnter spatial frequency: f(i)=');
f=0:0.01:1;
fo=0:0.01:1;
m=0:0.3:30;
mo=0:0.3:30;
fx=0.2;
fy=0.2;
rho=0.02;
sd=zeros(length(f),length(fo));
s=zeros(length(m),length(mo));
find=1;
foind=1;
mind=1;
moind=1;
for F=f
for Fo=fo
if ((F==fi)&&(Fo==fi))
sk(find,foind)=1;
else
sk(find,foind)=0;
end
g(find,foind)=(1/(fx*fy*sqrt(1-rho^2)))*exp((-1/(2*(1-rho^2)))*((F^2/fx^2)-((2*rho*F*Fo)/(fx*fy))-(Fo^2/fy^2)))/(fx.*fy.*sqrt(1-rho.^2));
sd(find,foind)=sd(find,foind)+conv(sk(find,foind),g(find,foind));
foind=foind+1;
end
find=find+1;
foind=1;
end
for l=1:k
s(mind,moind)=(1/k^2)*(s(mind,moind)+(sd(i/k,l/k)*exp(-j*2*pi*((i*m/k)-(l*mo/k)))));
moind=moind+1;
end
mind=mind+1;
moind=1;
end
mesh(f,fo,s);
hold on;
xlabel('\bff');
ylabel('\bffo');
zlabel('\bfs(m,mo)');

Best Answer

Time for you to learn how to use the debugger. At the command line give the command
dbstop if error
and then run the program. When it stops with the error, examine the size() of each of the indices on the left hand side of the assignment statement, and the size() of the expression that you are trying to assign (that is, the size() of the right hand side of the assignment statement)