x=[0:100:500];
y=3000+x.*250;
y1=y.*400;
How to plot both (x,y) and (x,y1) on one graph with suitable y axis ranges

 채택된 답변

Sam Chak
Sam Chak 2022년 6월 21일

2 개 추천

Maybe like this?
x = linspace(0, 100, 501);
y = 3000 + x*250;
yyaxis left
plot(x, y)
ylim([0 4e4])
yyaxis right
plot(x, 400*y)
ylim([0 14e6])

댓글 수: 3

Charuka Kumarasinghe
Charuka Kumarasinghe 2022년 6월 22일
Thank you very much
Sam Chak
Sam Chak 2022년 6월 22일
You are welcome, @Charuka Kumarasinghe. If you find the solution is helpful, please consider accepting ✔ and voting 👍 the Answer. Thanks!
Charuka Kumarasinghe
Charuka Kumarasinghe 2022년 6월 22일
Sure I will.

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

추가 답변 (1개)

Ajay Ahuja
Ajay Ahuja 2022년 6월 22일

0 개 추천

Thanks Sam for the answer. However, yyaxis left & yyaxis right commands don't seem to work in Simulink block. Any suggestions? Rgds!

댓글 수: 1

Sam Chak
Sam Chak 2022년 6월 22일
As far as I know, this left/right y-axis feature is currently not supported in the Simulink Scope.
If you really want to view two signals in one Scope, consider specifying the number of input ports on a Scope block.
For inserting a figure in a technical report, it is recommended that you send the data to Workspace and plot them out using yyaxis in MATLAB.

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2022년 6월 21일

댓글:

2022년 6월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by