Hello, I need to plot 31 curves and their color needs to be according to a third variable that varies from 1 to 5. I tried writing the code as follows:
colorspec1 = colormap(jet(5));for i = 1:31 for j = 1:5 if MA(i,2) == j semilogx(All_112(:,1), All_112(:,i+1),'-', 'Linewidth', 2, 'Color', colorspec1(j,:)); hold all end legendInfo{j} = ['Wind Speed = ' num2str(j)]; endendlegend(legendInfo);
I am getting curves with varying colors, but something is wrong with the code as when I change the loop positions and define j before i, the color of some curves also changes, which should not happen. I am unable to fix this issue and would need your help. Another issue is that I need a legend with 5 different colored lines in the colormap to define the third variable, but unable to get that with this version of the code. Could you please give me some direction how to do that? Thanks.
Best Answer