INDEX EXCEEDS MATRIX DIMENSION??

1 次查看(过去 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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by