INDEX EXCEEDS MATRIX DIMENSION??

조회 수: 5 (최근 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