Finding the Unit Vector in the Direction of a Vector using Matrices and MATLAB

  • Context: MATLAB 
  • Thread starter Thread starter andyintranzit
  • Start date Start date
  • Tags Tags
    Matlab Matrices
Click For Summary
SUMMARY

The discussion centers on finding the unit vector in the direction of vector v starting from vector u using MATLAB. The correct formula is identified as option d) (v-u) / (sqrt(v-u)*(v-u)'), which normalizes the vector difference. Participants clarify that the function mag() is not valid in MATLAB, suggesting abs() instead for magnitude calculations. Additionally, the dot product of vectors is explained using both row and column vector notations.

PREREQUISITES
  • Basic understanding of vectors and matrices
  • Familiarity with MATLAB syntax and functions
  • Knowledge of vector normalization techniques
  • Understanding of dot product calculations in linear algebra
NEXT STEPS
  • Learn MATLAB vector operations and functions
  • Study vector normalization techniques in detail
  • Explore the concept of dot products and their applications
  • Practice using MATLAB for matrix algebra problems
USEFUL FOR

Students in physics or engineering courses, MATLAB users, and anyone learning about vector mathematics and matrix operations.

andyintranzit
Messages
6
Reaction score
0
Hey guys,

Sorry if this is the wrong forum. Someone bump it across if its not.

This is a question on one of my tests (im doing my first semester of Physics at university) and its got to do with the program Matlab.


We have two vectors u and v. Which of the following gives us the unit vector in the direction of v, starting from u?

a) (v-u)/(u*u')
b) (v-u) * (v - u)
c) (v-u)./mag(v-u)
d) (v-u) / (sqrt(v-u)*(v-u)')




'I understand some basic matrix algebra, but I am still pretty spun out about matrices. can someone guide me through this? (a) thanks!
 
Physics news on Phys.org
ok.. i think i can eliminate the middle two because...

for b) you can't multiply two identical vector matrices together? cause they'll be in the same form?

and for c) I am pretty sure that mag() isn't a Matlab function at all...
 
The answer is d.

No mag() is not a MATLAB function, perhaps they meant abs() which is a function to return the magnetude of a complex value. In any case sqrt(v-u)*(v-u)') is the correct divisor to normalize it.

BTW you know that for row vectors x and y that x*y' gives the dot product of x and y, right? If you happen to be using column vectors then it's just the simple modification of using x'*y of course.
 
Last edited:

Similar threads

  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 13 ·
Replies
13
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
Replies
5
Views
8K
  • · Replies 2 ·
Replies
2
Views
2K