function colorcurves(x,y,z)
%   colorcurves(x,y,z)
%   colorcurves(z)     % use 1,2,3,... for x,y
% plot columns of array z as curves vs x
% Note that you can rotate the graph for a 3 dimensional view
%   z: array of size m by n
%   x: vector of length m, or array of size m by n
%   y: vector of length n, or array of size m by n
%
% Example: show graphs of x^4+a*x^2-a/2 for x=-2:.1:2, a=-4:.4:4 together
%   [X,A] = ndgrid(-2:.1:2,-4:.4:4); 
%   colorcurves(X,A,X.^4+A.*X.^2-A/2)  % rotate graph with mouse!

if nargin==1
  z = x;
  [m,n] = size(z);
  x = 1:n;  
  y = 1:m;  
end
[m,n] = size(z);
if min(size(x))==1
  x = repmat(x(:),1,n);
end
if min(size(y))==1
  y = repmat(y(:)',m,1);
end
newplot
set(gca,'colororder',jet(n))
line(x,y,z)
grid on; 
view(0,0) 
cameratoolbar('SetMode','orbit');

