Use pdist() and vertcat() using for loop
5 次查看(过去 30 天)
显示 更早的评论
Hey. Gays!
I wanna calculate pairwise euclidean distance and stack this Concatenate arrays vertically.
X = rand(7,7);
n = size(X,2);
for i=1:n
C = vertcat(pdist(X(:,i)));
end
I want to get the result (7 x 21) which was stacked.
However, I just got (1 x 21) matrix.
Does anyone have idea to fix this for loop code?
0 个评论
采纳的回答
Matt J
2020-3-4
X = rand(7,7);
n = size(X,2);
C=cell(n,1);
for i=1:n
C{i}=pdist(X(:,i));
end
C=cell2mat(C);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!