inv(A) versus /A. Which of the two is the correct one
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
Let B be a n by 2 matrix and A is a 2 by 2 positive definite matrix. Which of the following two is correct
for i=1:n
B(i,:)*inv(A)*B(i,:)';
end
or
for i=1:n
(B(i,:)/A)*B(i,:)';
end
Best, Stef
回答(1 个)
Matt J
2015-2-12
Both are equivalent. For large matrices the 2nd would be more efficient.
Further efficiency would be gained by vectorizing. The whole loop is just,
sum( (B/A).*B, 2)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!