MATLAB Answers

AA
0

drawing two different graphs on the same figure

Asked by AA
on 13 Oct 2017
Latest activity Commented on by AA
on 13 Oct 2017
I want to draw two plots on the same graph. The first graph has 1279 rows which are dislayed in the graph in the following manner:
figure()
x = liamu(:,2);
y = col1iamu(:,1);
plot(x,y);
on the same figure then I want to draw a second graph with 1432 rows (the rows sometimes vary) and the x axis should be numbers cumulative integers (1,2,3,4,5,6... and so on corresponding to the individual row, ie row 1 has x axis 1, row 2 has x axis 2 and so on up until 1432. I want this second graph to be displayed in red.
thanks a lot

  0 Comments

Sign in to comment.

1 Answer

回答者: KSSV
2017 年 10 月 13 日

figure
hold on
plot(x1,y1,'b') ; % first graph plot with blue color
plot(x2,y2,'r') ; % sedond graph plot with blue color

  3 Comments

AA
2017 年 10 月 13 日
and what is x2? i dont have that as variable. i want to put integers as x2 corresponding to the rows. so how can i do that?
KSSV
2017 年 10 月 13 日
You can use x2 = x1(1:1432) ;
AA
2017 年 10 月 13 日
No i said that the number of rows will change. The x axis always has to correspond to the y-axis. I cannot just randomly take a number. I just want to plot the y-axis and every dot on the y axis corresponds to a cumulative number.

Sign in to comment.