MATLAB Answers

0

I keep getting a 'parse error' at '='

Asked by Nadine Nassar on 21 Sep 2019
Latest activity Commented on by Nadine Nassar on 27 Sep 2019
  • All my equal signs are underligned saying that there's a parse error, can someone help me with this?
function [r,theta] = polar_coordinates(x,y)
r = sqrt ((x^2)+(y^2))
if(x>0)
theta = arctan(x/y)
end
if (x<0)
if (y>0)
theta = arctan(x/y) + pi
if (y<0)
theta = arctan(x/y) - pi
if (y=0)
theta = pi
end
end
end
end

  0 Comments

Sign in to comment.

2 Answers

Answer by madhan ravi
on 21 Sep 2019
 Accepted Answer

Change arctan() to atan() and y=0 to y==0.
doc if

  1 Comment

Thanks a lot!!

Sign in to comment.


Answer by Bruno Luong
on 21 Sep 2019
 Accepted Answer

Test wth "=="
if (y==0)

  1 Comment

Thanks a lot!!

Sign in to comment.