Length of a plotted line

26 visualizzazioni (ultimi 30 giorni)
Frederik Reese
Frederik Reese il 7 Giu 2022
Commentato: Frederik Reese il 7 Giu 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 ?

Risposta accettata

Matt J
Matt J il 7 Giu 2022
Modificato: Matt J il 7 Giu 2022
h=plot(2:6);
xlength = h.XData(end)-h.XData(1)
xlength = 4
  3 Commenti
Matt J
Matt J il 7 Giu 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 il 7 Giu 2022
thanks for your great help.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by