title: Draw a line with non-Cartesian coordinates in MATLAB
body: <p>MATLAB's <a href="http://www.mathworks.com/help/matlab/ref/surf.html" rel="nofollow noreferrer"><code>surf</code></a> command allows you to pass it optional <code>X</code> and <code>Y</code> data that specify non-cartesian x-y components. (they essentially change the basis vectors). I desire to pass similar arguments to a function that will draw a line.</p>
  
  <p><b>How do I plot a line using a non-cartesian coordinate system?</b></p>
  
  <p>My apologies if my terminology is a little off. This still might technically be a cartesian space but it wouldn't be <em>square</em> in the sense that one unit in the x-direction is orthogonal to one unit in the y-direction. If you can correct my terminology, I would really appreciate it!</p>
  
  <p>EDIT:</p>
  
  <p>Below better demonstrates what I mean:</p>
  
  <p>The commands:</p>
  
  <pre><code>datA=1:10;
  datB=1:10;
  X=cosd(8*datA)'*datB;
  Y=datA'*log10(datB*3);
  Z=ones(size(datA'))*cosd(datB);
  XX=X./(1+Z);
  YY=Y./(1+Z);
  surf(XX,YY,eye(10)); view([0 0 1])
  </code></pre>
  
  <p>produces the following graph:</p>
  
  <p><a href="https://i.stack.imgur.com/ERyrE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ERyrE.jpg" alt="Non-Cartesian Surf"></a></p>
  
  <p>Here, the X and Y dimensions are not orthogonal nor equi-spaced. One unit in x could correspond to 5 cm in the x direction but the next one unit in x could correspond to 2 cm in the x direction + 1 cm in the y direction. <b>I desire to replicate this functionality but drawing a line instead of a surf</b> For instance, I'm looking for a function where:</p>
  
  <pre><code>straightLine=[(1:10)' (1:10)'];
  my_line(XX,YY,straightLine(:,1),straightLine(:,2))
  </code></pre>
  
  <p>would produce a line that traced the red squares on the surf graph.</p>