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 日

0 投票

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 件のコメント

karna
karna 2013 年 2 月 21 日
hello, all the matrices sizes are ok.
karna
karna 2013 年 2 月 21 日
can u complile it and get exact output assign f(i)=0.2,0.5,0.75
Walter Roberson
Walter Roberson 2013 年 2 月 21 日
So you are trying to store three values in one array location?
karna
karna 2013 年 2 月 21 日
編集済み: Walter Roberson 2013 年 2 月 21 日
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)))));
Walter Roberson
Walter Roberson 2013 年 2 月 21 日
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 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by