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

In summary, the conversation is about a question on a physics test that involves using Matlab to find the unit vector in the direction of v from u. The options given are (a) (v-u)/(u*u'), (b) (v-u) * (v - u), (c) (v-u)./mag(v-u), and (d) (v-u) / (sqrt(v-u)*(v-u)'). The correct answer is (d) and the confusion arises from not understanding matrix algebra and the use of functions in Matlab.
  • #1
andyintranzit
6
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
  • #2
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...
 
  • #3
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:

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

1. What are matrices and how are they used in Matlab?

Matrices are rectangular arrays of numbers, symbols, or expressions that are arranged in rows and columns. In Matlab, matrices are used to store data and perform various mathematical operations such as addition, subtraction, multiplication, and inversion.

2. How do I create a matrix in Matlab?

To create a matrix in Matlab, you can use the matrix function and specify the size of the matrix, or you can enter the elements of the matrix directly using square brackets. For example, A = matrix(3,4) will create a 3x4 matrix, and B = [1 2 3; 4 5 6] will create a 2x3 matrix with the specified elements.

3. What is the difference between a row vector and a column vector in Matlab?

A row vector is a matrix with only one row, while a column vector is a matrix with only one column. In Matlab, row vectors are created using square brackets, while column vectors are created using semicolons. For example, row_vec = [1 2 3] and col_vec = [1; 2; 3].

4. How do I perform matrix multiplication in Matlab?

To perform matrix multiplication in Matlab, you can use the multiply function or the * operator. The matrices must have compatible dimensions, where the number of columns in the first matrix must match the number of rows in the second matrix. For example, C = multiply(A, B) or C = A * B.

5. Can I use Matlab to solve systems of linear equations using matrices?

Yes, Matlab has built-in functions such as inv and \ that can be used to solve systems of linear equations represented by matrices. For example, x = inv(A) * b or x = A \ b, where x is the solution vector, A is the coefficient matrix, and b is the constant vector.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Introductory Physics Homework Help
2
Replies
44
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
686
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
7K
  • Advanced Physics Homework Help
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Replies
5
Views
1K
  • Special and General Relativity
3
Replies
78
Views
4K
Back
Top