Using matlab to find vectors that are orthogonal to another vector.

조회 수: 238 (최근 30일)
Lee Ming De
Lee Ming De 2019년 11월 7일
편집: David Goodmanson 2023년 5월 10일
Is there a way that matlab can be used to find a general solution for vectors that are orthogonal to another vector. (eg, (1,1) )? Without using matlab, i can get the general solution which is x =-y, but i cant find a way to do this using matlab.

채택된 답변

Jan
Jan 2019년 11월 7일
편집: Jan 2019년 11월 7일
Do you mean 2D vectors?
v = rand(1, 2) % Any test vector
vp = [-v(2), v(1)]
dot(v, vp) % Orthogonal means: dot product is 0
So "x=-y" is a part of the solution. Add "y=x" and you get one of the two perpendicular vectors. -vp is the other one.
  댓글 수: 2
Oghenetega Oguns
Oghenetega Oguns 2023년 5월 9일
What about when the vector is 3D?
Thanks
David Goodmanson
David Goodmanson 2023년 5월 10일
편집: David Goodmanson 2023년 5월 10일
Hi O^2,
n = 5;
v = rand(n,1)
% make sure that v is a row vector, just in case it was a column vector
v = v(:).'
% find a set of n-1 mutually orthogonal column vectors
% that are all perpendicular to v.
n = null(v)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by