euclidean distance between two cell.
1 view (last 30 days)
Show older comments
Hello,
i have two cell.
Z1={1x3}{1z3} Z2={1x3}{1x3}{1x3}
i need euclidean distance between Z1 a Z2.
can anyone help ?
Thanks.
2 Comments
Kevin Claytor
on 11 Feb 2014
Please elaborate?
Euclidean distance is typically between two points eg; (x1,y1) and (x2,y2).
Are the contents of Z1 and Z2 a pair of points? Are the contents of Z1 one half of the pair and the contents of Z2 another half?
Additionally your two cell matrices are of different size, do you want Euclidean distance between the contents of every cell in Z1 to every cell in Z2, or between corresponding cells in Z1 to Z2?
Accepted Answer
Mischa Kim
on 11 Feb 2014
Edited: Mischa Kim
on 11 Feb 2014
Thomas, use
pdist([reshape(cell2mat(Z1),2,3); reshape(cell2mat(Z2),3,3)])
assumming that Z1 contains two cells of 1-by-3's, and Z2 contains three cells of 1-by-3's.
5 Comments
Mischa Kim
on 11 Feb 2014
Edited: Mischa Kim
on 11 Feb 2014
Well, it works for your specific requirements, but you can easily generalize it. In
cell2mat(Z1),2,3
the 2 denotes the number of vectors, 3 , the length of each vector. Same applies to Z2.
Does that answer your question?
More Answers (0)
See Also
Categories
Find more on Statistics and Machine Learning Toolbox 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!