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.

1 view (last 30 days)
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

Answers (1)

Guillaume
Guillaume on 15 May 2015
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 Comments
Guillaume
Guillaume on 15 May 2015
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

Sign in to comment.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!