How to obtain orthogonal (not orthonormal) vectors from "orth" or "qr"?
19 views (last 30 days)
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.
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
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
%s show that u is also orthogonal to the qi