Making all the plots to start from the same point.

조회 수: 10 (최근 30일)
Bhargavi
Bhargavi 2011년 9월 26일
I have four plots on a single graph. Each of those plots start from different points on the y axis. What do I do if I want all of them to start from a specified point so that I can see the pattern of my plots. I know I should add/subtract values from my y axis data so that they all start at the same point. But how do I do it?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 9월 26일
x=1:10;
y1=1:10;
y2=10:10:100;
figure(1);plot(x,y1,'r',x,y2,'b');
figure(2);plot(x,y1,'r',x,y2-y2(1)+y1(1),'b');
  댓글 수: 2
Bhargavi
Bhargavi 2011년 9월 26일
I don't quiet get you. Could you explain it a little bit.
Fangjun Jiang
Fangjun Jiang 2011년 9월 26일
y2 is a vector,
NewY2=y2-y2(1) subtract the whole vector with the first element of y2, so the first element of NewY2 would be 0
NewY2=y2-y2(1)+y1(1) would further add the first element of y1, so now the first element of NewY2 and Y1 are equal values.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 9월 26일
Let Y0 be the Y value that you want them all to start at. Then,
plot(x,y1-y1(1)+Y0,'r', x,y2-y2(1)+Y0,'g', x,y3-y3(1)+Y0,'b', x,y4-y4(1)+Y0,'c')

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by