plotting multiple graphs and adding a straight line

3 vues (au cours des 30 derniers jours)
Lim Zhi Yang
Lim Zhi Yang le 1 Oct 2020
Commenté : Star Strider le 1 Oct 2020
I am trying to plot multiple graphs, and I want to add a straight line of y = 2.3 into the graph but it only shows my first two plots which are x1,OA and x2,OF.
here is my code
x1 = [0:1:101];
OA = 0.00022494*x1.^2;
x2 = [0:1:74.4];
OF = -0.00018056*x2.^2;
x3 = [101:1:265];
AC = 2.3;
plot(x1,OA,'r',x2,OF,'r',x3,AC,'r')

Réponse acceptée

Star Strider
Star Strider le 1 Oct 2020
There are at least 2 ways to do that:
x1 = [0:1:101];
OA = 0.00022494*x1.^2;
x2 = [0:1:74.4];
OF = -0.00018056*x2.^2;
x3 = [101:1:265];
AC = 2.3;
figure
plot(x1,OA,'r',x2,OF,'r',x3,AC,'r')
yline(2.3) % First Option
figure
plot(x1,OA,'r',x2,OF,'r',x3,AC,'r')
hold on
plot(xlim, [1 1]*2.3, '-b') % Second Option
hold off
.
  2 commentaires
Lim Zhi Yang
Lim Zhi Yang le 1 Oct 2020
that works thanks so much !!
Star Strider
Star Strider le 1 Oct 2020
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by