How to code orthogonal unit vectors?

조회 수: 3 (최근 30일)
Jenny Andersen
Jenny Andersen 2019년 11월 18일
댓글: Rena Berman 2019년 12월 12일
Hi, I have two vectors, u = (u1, u2, u3) and the vector v = (v1, v2, v3) with the lenght of 1. The two vectors are orthagonal to each other and the first coordinate is 0. I am trying to figure out how to write this in matlab. I have tried the following:
u=input('Please enter a vector u=[u1 u2 u3]: ');
v1 = [0 u(2) u(3)];
v1 = v1 / norm(v1);
u = cross(u,v);
disp(' ');
% Vectors are calculated
v1=1*u;
v2=2*u;
v3=3*u;
v4=4*u;
But it does not seem to be working so I guess some variable/variables are not correct. Can you see what is wrong?
  댓글 수: 1
Rena Berman
Rena Berman 2019년 12월 12일
(Answers Dev) Restored edit

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

채택된 답변

Steven Lord
Steven Lord 2019년 11월 18일
Nowhere in your code did you define a variable named v, so line 4 of the code you posted should (and will) throw an error. Did you mean to use v1 there?
After getting past that line, again nowhere in your code is the variable w defined so the line "v1 = 1*w;" will throw an error. Maybe you meant to assign the output of cross to a variable named w?

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by