How to obtain orthogonal (not orthonormal) vectors from "orth" or "qr"?

40 views (last 30 days)
FW
FW on 12 Dec 2021
Edited: FW on 12 Dec 2021
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.
  12 Comments
FW
FW on 12 Dec 2021
You are right until "We can compute an orthonormal basis for the range space of B = [b1 b2 b3]. Those basis vectors are the colums of Q = orth(B). Q = [q1 q2 q3]. I assume that's what is meant by "orthonomalize b1, b2, and b3."
Now, take m, and orthogonalize m, with respect to q1, q2, q3 to obtain another vector u. This implies dot(u, q1) = dot(u,q2)=dot(u,q3) =0. However, u is not normalized. The length of u is taken as intensity.

Sign in to comment.

Answers (1)

Paul
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
ans = logical
1
% 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
ans = 1×3
1.0e+-11 * -0.3567 -0.6558 -0.8104
%s show that u is also orthogonal to the qi
u.'*Q
ans = 1×3
1.0e+-13 * 0.3722 0.1427 0.2941
  3 Comments
FW
FW on 12 Dec 2021
Yes, I agree this probably isn't the best approach bc of large dot product. The classical method is working pretty well. As I said earlier, I was exploring built-in MATLAB functions. It seems there is none. Thanks for your effort.

Sign in to comment.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by