MATLAB: Can anyone help me fix the code

different color on same plotsawtooth plot

Hello everyone,
i have a big problem with my code. I am trying to generate the graph in the attached file and i cannot. I attached my matlab code as well.
The code receives a range of temperature/wavelength values and i want my plot of phase vs temperature to be like sawtooth. If anyone can improve it or has any tips and suggestions for fixing, it is totally acceptable.
Also in my code there is a vector R (reflectance) which i want to plot the graph R vs lamda, for a variety of L, in the same figure with different colors. How i could do that?
<<
>>
Thanks a lot in advance and sorry for such a big text Dimitris

Best Answer

For the former, organize the data by column in two commensurately-sized arrays of T, phi. plot will then treat each column as a new line. If there aren't the same number of data points available for each, fill the shorter columns with NaN and plot will ignore those entries. Put all NaN entries at beginning or end of each column to avoid broken lines.
For the latter, after the first call to plot
hold on
plot(secondX,secondY,lineStyleTriplet)
See
doc plot
for details and read thru the linestyle properties section on how to adjust colors, etc., by line handle.
Related Question