-2

I am plotting 4 different vectors in same graph. Although MATLAB is assigning them different colours, I want to assign them my own colours. How can I do this? I also want to show the legend. Here is my code:

%Plotting of final solutions
a = 0:h:5.01;
z=1:1:N+2;
%ex=exact
up=upwind(z,M+1);
lf = laxfriedrich(z,M+1);
lw = laxwendroff(z,M+1);
oo = otherone(z,M+1);
plot(a,up,'o',a,lf,'o',a,lw,'o',a,oo,'o');
%plot (a,lf,'o',a,oo,'o');
axis([0,5,-1,1]);
4

1 回答 1

1

您可以通过许多不同的方式指定颜色,最简单的是:

plot(a, up, 'ro')
hold on
plot(a, lf, 'bo')
plot(a, lw, 'go')
plot(a, oo, 'yo')
legend;

查看 Plot > LineSpec的文档(如果您想要更多,请查看 colorspec)

于 2013-09-08T09:41:08.230 回答