what will be the solution for this error

function idx=nomc(meas)
W=SimilarMatrix(meas,1);
D=diag(sum(W));
L=D-W;
Lsym=(D^(-1/2))*L*(D^(-1/2));
[ev ed]=eig(Lsym);
d=diag(ed); %#ok<NASGU>
V=ev(:,1:3);
for i=1:250
for j=1:7
U(i,j)=V(i,j)/sqrt(sum(V(i,:).^2)); %#ok<AGROW>
end
end
idx=kmeans(U,3);
figure;plot(idx);
result=[length(find(idx==1)),length(find(idx==2)),length(find(idx==3))];
getting error
??? Attempted to access V(1,4); index out of bounds because
size(V)=[143,3].
Error in ==> nomc at 11
U(i,j)=V(i,j)/sqrt(sum(V(i,:).^2)); %#ok<AGROW>
Error in ==> Normalizemeanseg at 120
f=nomc(y);

2 Kommentare

Rushikesh Tade
Rushikesh Tade am 12 Sep. 2014
can you provide "meas" variable in mat format or provide dimensions?
meas is <143x256x3 double>

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Titus Edelhofer
Titus Edelhofer am 12 Sep. 2014

0 Stimmen

Hi,
you write
V = ev(:, 1:3);
so V has three columns. But your loop on j is
for j=1:7
That doesn't match ...
Titus

4 Kommentare

if i write
for j=1:3
still giving same error
Pierre Benoit
Pierre Benoit am 12 Sep. 2014
Bearbeitet: Pierre Benoit am 12 Sep. 2014
Well you should check the value of i then. You should use the sizes of V for your loop boundaries rather than some magic numbers.
Type
dbstop if error
in your command window before running your code, it will be easier to understand what went wrong.
Poonam, I think you're mistaken. If the error says
Attempted to access V(1,4);
and your code is
for j=1:3
Then there is no way the second index of V could be 4 in this line
U(i,j)=V(i,j).....
Pierre Benoit
Pierre Benoit am 12 Sep. 2014
Bearbeitet: Pierre Benoit am 12 Sep. 2014
Well, my guess was that this is no longer j that was causing a problem but i since the boundary of this loop is also quite arbitrary. And, maybe the author forgot to tell us or didn't see that the error changed a little.
But at this point, we can only guess given how little information we have.

Melden Sie sich an, um zu kommentieren.

Kategorien

Produkte

Gefragt:

am 12 Sep. 2014

Bearbeitet:

am 12 Sep. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by