MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Elysi Cochin
on 12 Feb 2013

i have a matfile with x and y values as shown in the link below...

http://img832.imageshack.us/img832/6010/examplecx.png

the x values are [1;2;3;4;5]..... for these x values and taking each column in the variable y, i want to plot a graph......

please can someone help me plot these 5 lines in one graph with each line in different color..... please do reply

i wanted the x-axis and y-axis markings to be as shown in the link below

http://img818.imageshack.us/img818/6365/21284279.png

please do reply....

*No products are associated with this question.*

Answer by Azzi Abdelmalek
on 12 Feb 2013

Edited by Azzi Abdelmalek
on 12 Feb 2013

Accepted answer

col='rgbkc' hold on for ii=1:5 line(x,y(:,ii),'color',col(ii),'Marker','o','LineStyle','--','markerfacecolor',col(ii),'Markersize',6) end legend({'curv1','curv2','curv3','curv4','curv5'},'location','SouthEast') xlabel('x') ylabel('y') set(gca,'ylim',[0 max(y(:))]) hold off

Answer by Ahmed
on 12 Feb 2013

if true % hold on for i=2:1:5 plot(x,y(:,i),'b-+','LineWidth',1,'MarkerSize',5); xlabel('x values'); ylabel('y values'); end end you may change the values of i according to thr columns you want to plot ok?

Elysi Cochin
on 12 Feb 2013

how to give different colors for each line and how to give the x marking as 10, 20 ,30,....100..... and y marking as 1,1.5,2,2.5,3........5

please do reply.....

## 0 Comments