Subscripted assignment dimension mismatch. what does it mean

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)');

 채택된 답변

Walter Roberson
Walter Roberson 2013년 2월 21일
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)

댓글 수: 5

hello, all the matrices sizes are ok.
can u complile it and get exact output assign f(i)=0.2,0.5,0.75
So you are trying to store three values in one array location?
k=3;
we has to assign f(i) any 3 values from 0 to 1.
once try to compile the code.
i'm getting the error for 11 line from last.
s(mind,moind)=(1/k^2)*(s(mind,moind)+(sd(i/k,l/k)*exp(-j*2*pi*((i*m/k)-(l*mo/k)))));
Numeric arrays cannot store multiple values in the same location. You will need to either use multiple locations (e.g., several columns for the same row) or else use cell arrays.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by