title: How can I convert cartesian coordinates to polar coordinates using function
body: <p>I'm trying to create a function in MATLAB that takes a cartesian coordinate and converts it to polar.</p>
  
  <pre><code>function [homework5] = Cartesian(X,Y)
  
  M = size(X,1)
  
  for N=1:M
  if X,Y;
  
  r=sqrt(X^2+Y^2)
  theta=atan(Y/X)
  
  
  else
  disp('input incorrect')
  
  
  end   
  
   if r &gt; 10
      disp('Far from Origin')
  else
      disp('Close to Origin')
  
   end
  
  end
  </code></pre>
  
  <p>I'm extremely new to MATLAB and my searches for the answer and reading tutorials e.t.c have proved futile. </p>
  
  <p>I have it to where it converts 1 coordinate just fine, but I need to convert multiple coordinates at once (hence the forloop) but I can't get it! The user needs to be able to enter an array like this: >>Cartesian = [2,3;4,5;6,7] and have each row converted.</p>
  
  <p>Thanks for any help!</p>