Matlab Legend Problem

  1. I am trying to make a plot of four pairs of time series. The plot appears fine; I have two lines in each color as I want. The problem, in this case, is that the first two legend items both have red lines, and the second two both have black lines. I want each legend entry to match the color of the pair of lines on the plot. My code is below; I hope someone can help. Some comments on the code:

    z is the counter - I have a loop that calculates the data and puts in into plotdata for each run. The four correspond to four values of p.

    hold on
    colors=['r' 'k' 'g' 'b'];
    xlabel('Time, {\itt}','FontSize',24,'FontName','Times New Roman')
    ylabel('Fractional Population','FontSize',24,'FontName','Times New Roman')
    set(gca,'FontSize',24,'FontName','Times New Roman')
    grid on
    legend(char({strcat('{\itp} =',num2str(p(1:z)'))}))

  2. jcsd
Know someone interested in this topic? Share this thead via email, Google+, Twitter, or Facebook

Have something to add?

Draft saved Draft deleted