I have a cell array of 100*8. Each cell contains N*24 matrix. I need to find the inter-class euclidian distance. But the error is coming: Subscripted assignment dimension mismatch.

k=1;
while k<100
if(k==1)
for m=1:99
for n=1:8
impsum(k,m,n)=pdist2(RetFet{1,n},RetFet{m+1,n},'euclidean');
end
end
else
for m=1:(k-1)
for n=1:8
impsum(k,m,n)=pdist2(RetFet{k,1},RetFet{m,n},'euclidean');
end
end
for m=k:99
for n=1:8
impsum(k,m,n)=pdist2(RetFet{k,1},RetFet{m+1,n},'euclidean');
end
end
end
k=k+1;
end

Réponses (1)

You're trying to assign a matrix (the result of pdist2) to a scalar ( impsum(k, m, n)). Of course, you're going to get a subscripted assignment mismatch.
Possibly, you meant
impsum{k,m,n} = ...
Or maybe you meant to calculate the sum of pdist2?

2 commentaires

I am using a 3-D matrix. According to you, should i use cell array for this.
I don't know what you should be using, but you can't stuff a 2D matrix into each cell of a 3D matrix. You can only put a single scalar into each cell.
So, either you meant to do something with the result of pdist2 to produce a scalar, or you need to put these 2D matrices into something else. Two possibilities: A cell array or a 5D matrix.:
impsum{k ,m, n} = some2Dmatrix
%or
impsum(k, m, n, :, :) = some2Dmatrix

Connectez-vous pour commenter.

Catégories

Question posée :

le 15 Mai 2015

Commenté :

le 15 Mai 2015

Community Treasure Hunt

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

Start Hunting!

Translated by