Question: Using matlab create a function that will normalize a vector. This function will take in a vector and return a vector that goes in the
Using matlab create a function that will normalize a vector.
This function will take in a vector and return a vector that goes in the same direction, but has a magnitude of one. You should think of the Pythagorean theorem to decide how to "shrink" a vector to length 1.
Hint: This function should utilize the magnitude function to find the length of the vector. Warning you should only use the magnitude function once in your normalize function!
The function for magnitude is
function the_mag = magnitude (my_vector )
my_vector.x = my_vector.x^2;
my_vector.y = my_vector.y^2;
the_mag = sqrt(my_vector.x+my_vector.y);
end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
