I have been using matlab2tikz to generate a lot of my plots, but I am finding it struggling at this particular job so would like to inquire about how to do it properly in pgfplots / tikz.
Essentially I would like to plot a number of curves on one graph, and have a spectrum color map color them with colors evenly distributed on the spectrum. In MATLAB this is quite simple:
figure
const = linspace(0,pi/4,50)';
x = linspace(0,pi,128);
plots = sin(-const*x)';
noOfLines = length(const);
cmp = jet(noOfLines);
hLine = plot(plots);
for line = 1:noOfLines
set(hLine(line),'Color',cmp(line,:));
end
set(hLine,'LineWidth',1.5);

I can export this with matlab2tikz and compile it which produces this gorgeous plot:

The problem is the tikz code is kind of brute forced. It starts with 50 costumed \definecolor
\definecolor{mycolor1}{rgb}{0.00000,0.00000,0.53846}%
\definecolor{mycolor2}{rgb}{0.00000,0.00000,0.61538}%
\definecolor{mycolor3}{rgb}{0.00000,0.07692,1.00000}% ...
for each color that is going to be used, and then 50 \addplot
\addplot [color=mycolor2,solid,line width=1.5pt,forget plot]
table[row sep=crcr]{1 0\\
2 -0.000396497032881626\\
3 -0.000792994003429991\\
to plot each line with the correct color. I understand I am asking an aweful lot from matlab2tikz so I guess I would like to know how to do this properly using tikz / pgfplots. I have another data set that is similar but it has a lot more plots and comes out to 1.3 mb, taking a long time to compile.
I am happy with creating a pgfplot from a dataset that is in a text file with just the raw data (which would be the plots matrix in my MATLAB workspace in the above example), but have no idea how to proceed from here. Thanks.
EDIT:
In MATLAB my code will be in the workspace like:

I then dlmwrite it to a .dat file by:
dlmwrite('data.dat',myData,'delimiter', '\t');
Then I try to \addplot3 and get:

This is my dataset:
0.99934 1.0005 1.0007 1.0001 0.99934
1.0029 1.0012 0.99933 0.99862 0.9979
1.0013 0.9988 1.0023 0.99525 0.99771
0.99774 0.99582 0.9943 0.99217 0.98699
0.9912 0.98502 0.97814 0.96116 0.94135
0.97022 0.94084 0.89332 0.83747 0.77688
0.88784 0.75475 0.61326 0.462 0.3339
0.58506 0.30003 0.11623 0.034422 0.0078042
0.099072 0.0090417 0.0031278 0.00023727 0.00050435
-0.0014491 0.00053296 -0.00028736 -0.0021953 0.00056537
-0.0024348 5.2456e-05 0.001471 5.6913e-05 -0.0010844
0.0019199 -0.0023666 0.00065858 -2.7668e-05 0.00034113
Thanks for all your help.


[col sep=tab]but still get the same picture. Thanks – Steve Hatcher Aug 29 '14 at 03:13