INDEX EXCEEDS MATRIX DIMENSION??
24 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%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 commentaires
Kristopher
le 14 Fév 2014
Modifié(e) : Kristopher
le 14 Fév 2014
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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!