How can to compute the following case?
古いコメントを表示
If there is a cell D and its size 6*9 and this cell contains matrices. (Attached)
in this line: svd(D{1,1}.'*D{1,2});
how can I change the indices of D to do the multiplication of all combinations of D but without repeat the similar combinations such as:
D{1,1}.'*D{1,2} and D{1,2}.'*D{1,1}
and exclude the similar indicies such as
D{1,1}.'*D{1,1} and so on ...
Then store all the results in "distance"
[U,S,V] = svd(D{1,1}.'*D{1,2});
distance = sqrt(sum(arrayfun(@(i)acos(S(i,i))^2,1:4)))
採用された回答
その他の回答 (1 件)
load(websave("D.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1436693/D.mat"));
for i=1:size(D, 1)
for j=1:size(D, 2)
for i1=1:size(D, 1)
for j1=1:size(D, 2)
S{i,j,i1,j1} = D{i,j} - D{i1,j1};
end
end
end
end
whos
S{1, 2, 3, 4} % for example: D{1,2}-D{3,4}
5 件のコメント
Torsten
2023 年 7 月 18 日
[U,S,V] = svd(directions{i,j}.'*directions{i,j});
This makes no sense. If you use identical directions to compare, you'll of course get a distance of 0 for every pair.
M
2023 年 7 月 18 日
Torsten
2023 年 7 月 18 日
Are you sure all cell matrices directions{i,j} have the same number of columns ? The distance formula only applies under this condition.
M
2023 年 7 月 18 日
カテゴリ
ヘルプ センター および File Exchange で Mathematics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!