INDEX EXCEEDS MATRIX DIMENSION??

2 ビュー (過去 30 日間)
Drishya
Drishya 2014 年 2 月 14 日
編集済み: Kristopher 2014 年 2 月 14 日
%while running this function,i got an error message like this... %%%%doing KWFLICM
function [G1,U1]=calculateG(U1,D1,I1,m1,c,C)
[m,n]=size(I1);
G1=cell(m,n);
for i=1:m
for j=1:n
G1{i,j}=zeros(c,1);
end
end
for i=1:m
for j=1:n
for k=1:c
temp=0;
for x=i-1:i+1
for y=j-1:j+1
q=1;
if x>0&&x<m&&y>0&&y<n&&(x~=i||y~=j)
d=sqrt((i-x)^2+(j-y)^2);
% temp=temp+1/(1+d)*(1-U1{x,y}(k,1))^m1*(I1(x,y)-V2(k))^2;
% temp=temp+C{i,j}(1,q)*(1-U1{x,y}(k,1))^m1*(I1(x,y)-V2(k))^2;
temp=temp+1/(1+d)*C{i,j}(1,q)*(1-U1{x,y}(k,1))^m1*(1-D1{x,y}(k,1));
q=q+1;
end end end
G1{i,j}(k,1)=temp;
G(k)=temp;
end
for k=1:c
temp=0;
for z=1:c
% temp=temp+(G(k)/G(z))^(1/(m1-1));
a=1-D1{i,j}(z,1)+G(z);
if a~=0
temp=temp+((1-D1{i,j}(k,1)+G(k))/a)^(1/(m1-1));
else
temp=temp+((1-D1{i,j}(k,1)+G(k))/0.01)^(1/(m1-1));
end end
if temp~=0
U1{i,j}(k,1)=1/temp;
else
U1{i,j}(k,1)=1;
end
end
end
end
  2 件のコメント
Matt J
Matt J 2014 年 2 月 14 日
What does the DBSTOP command tell you?
Kristopher
Kristopher 2014 年 2 月 14 日
編集済み: Kristopher 2014 年 2 月 14 日
which line of code returns the error? Your code is pretty hard to read, but I would guess one of the loops that loops to index+1 is going past the bounds(end) or your matrix for that dimension.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by