title: Gradient of colors in a matlab plot
body: <p>I am trying to write a matlab script that would enable me to add color gradient to my 3D plot. I am performing the following test:</p>
  
  <blockquote>
    <p>function handle = coloured_line_3d(x, y, z, c)</p>
  
  <pre><code>handle = surface( [x(:), x(:)], [y(:), y(:)],[z(:), z(:)],[c(:),
  c(:)], 'EdgeColor', 'flat', 'FaceColor', 'none'  );
  end
  </code></pre>
  </blockquote>
  
  <pre><code>x = [1; 2; 3]
  y = [1; 2; 3]
  z = [1; 2; 3]
  c = [1 2 3]
  </code></pre>
  
  <p>Running this, the following warnings appear:</p>
  
  <pre><code> coloured_line_3d(x,y,z,c)
  
  ans =
  0.0029
  
  Warning: size(CData) must equal size(ZData) or size(ZData)-1 for flat shading 
  Warning: size(CData) must equal size(ZData) or size(ZData)-1 for flat shading 
  Warning: size(CData) must equal size(ZData) or size(ZData)-1 for flat shading 
  Warning: size(CData) must equal size(ZData) or size(ZData)-1 for flat shading 
  </code></pre>
  
  <p>and I get an empty plot.</p>
  
  <p>What is wrong with this?</p>