i want to plot a function say sin(x) for the interval 0:30 and then i want to continue this plot for some other function say ax+b (a,b are constants) for the interval 30:40,how can a manage this plot and also x-axis. Thanks

 채택된 답변

Image Analyst
Image Analyst 2014년 11월 25일

1 개 추천

Here's one way. Just make up each and stitch together:
x1 = linspace(0, 30, 100);
y1 = sin(x1);
x2 = linspace(30, 40, 30);
a = .15;
b = -5;
y2 = a*x2 + b;
x = [x1, x2];
y = [y1, y2];
plot(x, y, 'bo-');
grid on;
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);

댓글 수: 4

Image Analyst
Image Analyst 2014년 11월 25일
Of course you could also just plot x1,y1 and then call hold on and then plot x2,y2 separately.
Muhammad Usman
Muhammad Usman 2014년 11월 25일
Thankyou so very much
Image Analyst
Image Analyst 2014년 11월 25일
편집: Image Analyst 2014년 11월 25일
You're welcome. Thanks for accepting. If the ranges of the two y's are very much different , then you can also use plotyy() which will give each curve it's own independent Y axis (one on each side of the graph).
Muhammad Usman
Muhammad Usman 2014년 11월 26일
yes i got help about plotyy() in documentation but you solved my issue

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

추가 답변 (1개)

카테고리

도움말 센터File Exchange에서 Two y-axis에 대해 자세히 알아보기

태그

질문:

2014년 11월 25일

답변:

2015년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by