add line in a plot

4 vues (au cours des 30 derniers jours)
Ancalagon8
Ancalagon8 le 9 Juil 2020
Modifié(e) : Ancalagon8 le 6 Jan 2025
Hello I have a figure with datetime in x- axis. I want to plot a vertical line but through code where is the exact point but i receive an error.
Any ideas how to do this?

Réponses (1)

Steven Lord
Steven Lord le 9 Juil 2020
First, plot some duration data.
y = (0:59);
x = duration(0, y, 1);
plot(x, y);
Now add a line at a specific value. Note that since I plotted with duration data on the X axis, when creating an xline I must create it at a duration value. If I tried something like xline(15) that wouldn't work.
xline(duration(0, 15, 0))
  2 commentaires
Ancalagon8
Ancalagon8 le 9 Juil 2020
"Undefined function or variable 'xline'."
madhan ravi
madhan ravi le 9 Juil 2020
It was introduced in 2018b so if you’re using a prior release it won’t work.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion 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