フィルターのクリア

Attempted to access i(3); index out of bounds because numel(i)=2

1 回表示 (過去 30 日間)
Mahmoud Hassan
Mahmoud Hassan 2019 年 5 月 17 日
回答済み: Walter Roberson 2019 年 5 月 18 日
i am getting this error
"Attempted to access i(3); index out of bounds because numel(i)=2 ".
exactly in the line 289 below:
Table=[3*pi/4 2*pi/3 pi/2 pi/3 pi/4
5*pi/6 0 0 0 pi/6
pi 0 0 0 0
-5*pi/6 0 0 0 -pi/6
-3*pi/4 -2*pi/3 -pi/2 -pi/3 -pi/4];
for ind=1:length(CentroidBifX)
Klocal=K(CentroidBifY(ind)-2:CentroidBifY(ind)+2,CentroidBifX(ind)-2:CentroidBifX(ind)+2);
Klocal2=K(CentroidBifY(ind)-1:CentroidBifY(ind)+1,CentroidBifX(ind)-1:CentroidBifX(ind)+1);
Klocal(2:end-1,2:end-1)=0;
Klocal2(2:end-1,2:end-1)=0;
[i,j]=find(Klocal);
[i2,j2]=find(Klocal2);
length(i)
if length(i)> 3
for k=1:3
OrientationBif(ind,k)=Table(i2(k),j2(k));
dxBif(ind,k)=sin(OrientationBif(ind,k))*3;
dyBif(ind,k)=cos(OrientationBif(ind,k))*3;
end
else
for k=1:3
OrientationBif(ind,k)=Table(i(k),j(k)); "line of error"
dxBif(ind,k)=sin(OrientationBif(ind,k))*5;
dyBif(ind,k)=cos(OrientationBif(ind,k))*5;
end
end
end
  3 件のコメント
Mahmoud Hassan
Mahmoud Hassan 2019 年 5 月 18 日
you would understand the whole 289 lines if i put them all ?! and for your question i am just new to matlab and trying to understand some errors i have
madhan ravi
madhan ravi 2019 年 5 月 18 日
Sulaymon Eshkabilov's comment mistakenly posted as answer:
Hi,
Undefined function or variable 'CentroidBifX'? What is your set variable 'CentroidBifX'?

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 5 月 18 日
if length(i)> 3
so if is more than 3 long you execute this code
for k=1:3
OrientationBif(ind,k)=Table(i2(k),j2(k));
dxBif(ind,k)=sin(OrientationBif(ind,k))*3;
dyBif(ind,k)=cos(OrientationBif(ind,k))*3;
end
else
and if you got here, then i is empty, or i is length 1, or i is length 2, or i is length 3.
for k=1:3
OrientationBif(ind,k)=Table(i(k),j(k)); "line of error"
that is going to fail if i is empty, or length 1, or length 2. It is only going to work if i is length 3.
Based upon your error message, i is length 2. We, as outside observers, have no reason to expect that it will be any particular length.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

タグ

製品


リリース

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by