Length of a plotted line

6 vues (au cours des 30 derniers jours)
Frederik Reese
Frederik Reese le 7 Juin 2022
Commenté : Frederik Reese le 7 Juin 2022
Hi, I have plots like this:
I want to know, how I can get the length of the lines in the x axis in the plot. Is there a function or can anyone write a code for me ?

Réponse acceptée

Matt J
Matt J le 7 Juin 2022
Modifié(e) : Matt J le 7 Juin 2022
h=plot(2:6);
xlength = h.XData(end)-h.XData(1)
xlength = 4
  3 commentaires
Matt J
Matt J le 7 Juin 2022
If you download the files from here, it's a simple modification
h=plot([2:4,nan,5:7]);
[start,stop]=groupLims(groupTrue(~isnan(h.YData)),1);
xLength=sum( h.XData(stop)-h.XData(start) )
xLength = 4
Frederik Reese
Frederik Reese le 7 Juin 2022
thanks for your great help.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots 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