legend - Plotting multiple graphs with different colour on matlab -


i want draw 2 graphs in matlab different colors. want box in upper right corner names each of 2 graphs. code writing is:

x=1:1:max %err_t_coupled,err_t_uncoupled arrays figure plot(x, err_t_coupled,'red',x, err_t_uncoupled,'blue')  legend('uncoupled','coupled','location','northeast')  title('maximum error')  xlabel('iterations')  ylabel('maximum error wrt d-norm') 

it produces desired graph. in top right corner, draws red line both coupled , uncoupled. instead want red coupled , blue uncoupled. solutions?

the problem has fact err_t_coupled , err_t_uncoupled arrays, not vectors.

this work:

x=1:1:max %err_t_coupled,err_t_uncoupled arrays figure h1 = plot(x, err_t_coupled,'red'); hold on h2 = plot(x, err_t_uncoupled,'blue'); legend([h1(1) h2(1)], 'coupled','uncoupled','location','northeast')  title('maximum error')  xlabel('iterations')  ylabel('maximum error wrt d-norm') 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -