how to find orthonormal vector with condition?

47 ビュー (過去 30 日間)
Sara
Sara 2025 年 9 月 23 日 8:44
コメント済み: Sara 2025 年 9 月 25 日 10:50
Hello,
This should be simple, but I can't figure it out. I need to create an orthonormal vector whose x component is as close to 0 as possible. So far I know how to get the orthonormal basis of my vector but how can I find a vector within the basis that meets the condition of being as close to 0 as possible?
a = [x y z]; % my vector
n = null(a.'); % orthonormal basis
  2 件のコメント
Torsten
Torsten 2025 年 9 月 23 日 10:28
編集済み: Torsten 2025 年 9 月 23 日 11:20
If y = 0, take [0, 1, 0]. If y ~= 0, take [0,-z,y]/sqrt(y^2+z^2).
Sara
Sara 約6時間 前
Thanks! This was what I needed.

サインインしてコメントする。

回答 (2 件)

Matt J
Matt J 2025 年 9 月 23 日 13:03
n=[0,null([y,z])']

John D'Errico
John D'Errico 2025 年 9 月 23 日 13:04
編集済み: John D'Errico 2025 年 9 月 23 日 14:03
Confusing question. Which probably means I'm misunderstanding your goal here, or that I am myself confused, which is not uncommon. But I'll take a shot.
Consider a vector v.
v = randn(1,4)
v = 1×4
0.5393 0.4693 0.4517 -1.3974
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
I want to find a vector u orthogonal to v, but it must have the property that u(1)==0? That is simple.
U = null(v(2:end))
U = 3×2
-0.2930 0.9064 0.9342 0.2036 0.2036 0.3702
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
The columns of U contain 2 vectors, such that in each case if I expand them by padding a zero element as the first element, the new vectors will be orthogonal to v, AND they themselves have unit norm.
u1 = [0;U(:,1)]
u1 = 4×1
0 -0.2930 0.9342 0.2036
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
u2 = [0;U(:,2)]
u2 = 4×1
0 0.9064 0.2036 0.3702
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
dot(v,u1)
ans = 1.3878e-16
dot(v,u2)
ans = -2.7756e-16
norm(u1)
ans = 1
norm(u2)
ans = 1.0000
And to within floating point trash, they satisfy the requirements. u2 and u2 are not unique of course. But u1 and u2 form an orthonormal set with first element zero, that are each normal to v.
It would have been a somewhat more interesting question if the requirement was to find an orthonormal set with the property that u(1) was some other given number, perhaps 1/2. (Its not too difficult to modify the scheme I used in that case.) But zero is pretty easy.

カテゴリ

Help Center および File ExchangeDynamic System Models についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by