Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Matlab work out the xy2polar_vector.m. You can do a for loop over the entire vec

ID: 2890353 • Letter: M

Question

Matlab work out the xy2polar_vector.m. You can do a for loop over the entire vector x, y, and then treat each element as a scalar. Then you can call xy2polar_scalar to get the radius and angle. The pseudocode would be something like this:

for i in length(x)

[r(i), th(i)]= xy2polar_scalar (x(i), y(i));

end

function [r, thetal-xy2polar_vector(x,y) % convert 2D cartesian coordinates (x,y) into polar coordinates (r, theta) % input argument: vector x, y % output argument: vector r, theta % please put your code here end

Explanation / Answer

function [r,theta]=xy2polar_vector(x,y)

x=0:1;
y=1:2;
for i=1:numel(x)
r=sqrt(x(i)^2+y(i)^2)
theta=atan(y(i)/x(i))
end