How to plot a horizontal line?

5 vues (au cours des 30 derniers jours)
Mikhail Konovalov
Mikhail Konovalov le 12 Mai 2020
My function is just y=2050 and I need to plot it w/o using "yline", because it's not a graph, actually. I just type this:
x=[0:0.1:110];
y=[0:10:2060];
g=2050;
plot(x,g)
And I don't get anything. Like, completely anything:
And also after that I need to mark a point (100,2050) and be able to make it bigger than my graph.
How do I solve these problems?

Réponse acceptée

Mikhail Konovalov
Mikhail Konovalov le 13 Mai 2020
Modifié(e) : Mikhail Konovalov le 13 Mai 2020
Great thanks to drummer and darova! I finally have the graph I wanted. Final code:
x=[0:0.1:110];
y=[0:10:2060];
g=2050;
p1=plot(x,g+x*0,"g");
p1.LineWidth=2;
hold on
p2=plot(100,2050,"r*");
p2.LineWidth=15;
xlim([1 110])
Result:

Plus de réponses (2)

darova
darova le 12 Mai 2020
Try this
  5 commentaires
darova
darova le 13 Mai 2020
Can you make a simple sketch of the result you expect?
Mikhail Konovalov
Mikhail Konovalov le 13 Mai 2020
I've already got the result I wanted. Thank you!

Connectez-vous pour commenter.


drummer
drummer le 12 Mai 2020
Modifié(e) : drummer le 12 Mai 2020
y = 0:0.1:110;
x = 2050.* ones(length(y));
plot(y,x)
xlim([1 110])
  1 commentaire
Mikhail Konovalov
Mikhail Konovalov le 13 Mai 2020
Looks nice! And how do I set a point at (100;2050)?

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by