Evaluating svd() on slice of matrix array.

1 回表示 (過去 30 日間)
Morten Nissov
Morten Nissov 2020 年 1 月 20 日
編集済み: David Goodmanson 2020 年 1 月 23 日
I have an array of matrices such that
size(A) == [3, 3, 1e3]
for example. These 1000 [3x3] matrices must be orthonormal so I am attempting to project each one to the nearest orthonormal basis, using svd() and the approximation
This function is made to work on a single [3x3] matrix at a time however. A workaround could be using for loops like
[~,~,np] = size(A);
for i=1:np
[U,~,V] = svd(A(:,:,i));
A(:,:,i) = U*V';
end
but this function will be called very often with high numbers of matrices so I am attempting to make efficient. Is there a better way to do this?

回答 (1 件)

David Goodmanson
David Goodmanson 2020 年 1 月 23 日
編集済み: David Goodmanson 2020 年 1 月 23 日
Hi Morten
I take it that your matrices are close to being orthonomal already. Try
[Q, ~] = qr(A(:,:,i));
A(:,:,i) = Q;
which is about three times faster, not counting overhead to read and write to A(:,:,i). The result is slightly different, but of course still orthogonal.

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by