Practice with for and if statements Write a Matlab function

Practice with for and if statements

Write a Matlab function quadrant that returns the quadrant (1,2,3, or 4) of a list of angles in degrees. Assume 90 degrees is quadrant 2, 180 is quadrant 3, 270 is quadrant 4, etc.
Example:

Solution

function v = quadrant(input)

L =length(input);

for i = 1:L

if input(i) > 360

input(i) = input(i) + 360;

end

v(i) =floor(mod(input(i)/90,4)+1);

end

end

Practice with for and if statements Write a Matlab function quadrant that returns the quadrant (1,2,3, or 4) of a list of angles in degrees. Assume 90 degrees i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site