plot vectors of different lengths

I have two vectors, say x and y, with lengths 100 and 200 respectively. I'd like to plot them separately, but in the same figure and at the same scale. I can get them in the same figure with the following:
> subplot(2,1,1); plot(x);
> subplot(2,1,2); plot(y);
But this stretches both to fill the width of the window, so the scale for the plot of x is double that of the scale for y. How do I get the plots to use the same scale, so that the plot for x takes up half the width of the plot of y?
Thanks.

답변 (3개)

the cyclist
the cyclist 2012년 1월 15일

0 개 추천

Is this what you mean?
subplot(2,1,1), plot(1:10)
set(gca,'XLim',[0 20])
subplot(2,1,2), plot(1:20)
set(gca,'XLim',[0 20])
Betty
Betty 2012년 1월 15일

0 개 추천

Not exactly. I'm trying to produce a plot like the one here:
Using my code or yours, it stretches each plot out to the width of the window. I'd like to not have them stretched out.
Thank you!

댓글 수: 1

the cyclist
the cyclist 2012년 1월 15일
This "answer" would be better understood if you either edited your question to include this info, or just placed it as a comment on my (incorrect) answer.

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

the cyclist
the cyclist 2012년 1월 15일

0 개 추천

Here is one way. You'll need adjust the position parameters to get exactly what you want, but that shouldn't be too hard.
figure
subplot('Position',[0.1 0.55 0.8 0.4]),plot(1:20)
subplot('Position',[0.1 0.05 0.4 0.4]),plot(1:10)
You might want to read "doc subplot". In particular, note that if you position a set of axes such that the overlap an existing one, the existing one will be deleted.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2012년 1월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by