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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started