How to draw two plots in one figure?

12 vues (au cours des 30 derniers jours)
Nazila Pourhajy
Nazila Pourhajy le 31 Mai 2022
Hi everyone.
I have two plots like this:
I want to have two plots in one figure like this in matlab. But I dont know what to do. please help me Thanks alot..
When I use this commands:
plot(x,y1);
hold on;
plot(x,y2);
hold off;
The result is as follow:
Becaues the values of y in two plots are different.

Réponse acceptée

Simon Chan
Simon Chan le 31 Mai 2022
Use function yyaxis
  1 commentaire
Nazila Pourhajy
Nazila Pourhajy le 31 Mai 2022
Thanks alot my friend.My problem was solved.

Connectez-vous pour commenter.

Plus de réponses (1)

Abhijit Nayak
Abhijit Nayak le 31 Mai 2022
From my understanding, you are looking for a way to have two plots in one figure with a common x-axis. You can use “yyaxis” function for such scenario.
For further reference, you can refer to the following MATLAB documentation link- .

Catégories

En savoir plus sur Graphics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by