How to obtain orthogonal (not orthonormal) vectors from "orth" or "qr"?
38 views (last 30 days)
Show older comments
Suppose there is a set of vectors v1, v2, v3, v4 with V=[v1, v2, v3, v4]. The vectors have very large number of data points ~ 100k. I wanted to orthogonalize them with each other. The classical Gram-Schmidt is not recommended by majority of authors for real data. The symbolic version of orth has skipnormalization. https://www.mathworks.com/help/symbolic/orth.html, but it does not work on orth(V). Error using orth Too many input arguments.
What would be the best way to generate orthogonal basis vectors rather orthonormal basis vectors using built in MATLAB functions? Thanks.
Answers (1)
Paul
on 12 Dec 2021
I think this at least illustrates what you're trying to accomplish. It might not be (probably isn't) the best way
% generate some sample data
rng(100);
m = rand(1e5,1);
B = rand(1e5,3);
% verify that vectors bi are linearly independent
rank(B) == 3
% compute the desired result
Q = orth(B);
a = sum(m.*Q);
u = m - sum(a.*Q,2); % u is the component of m that is orthogonal to the bi and the qi
% verify that u is orthogonal to the bi
u.'*B
%s show that u is also orthogonal to the qi
u.'*Q
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!