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

 Respuesta aceptada

Sam Chak
Sam Chak el 21 de Jun. de 2022
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 comentarios

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

Iniciar sesión para comentar.

Más respuestas (1)

Ajay Ahuja
Ajay Ahuja el 22 de Jun. de 2022

0 votos

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

1 comentario

Sam Chak
Sam Chak el 22 de Jun. de 2022
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Centro de ayuda y File Exchange.

Preguntada:

el 21 de Jun. de 2022

Comentada:

el 22 de Jun. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by