Length of a plotted line

26 次查看(过去 30 天)
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 ?

采纳的回答

Matt J
Matt J 2022-6-7
编辑:Matt J 2022-6-7
h=plot(2:6);
xlength = h.XData(end)-h.XData(1)
xlength = 4
  3 个评论
Matt J
Matt J 2022-6-7
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 2022-6-7
thanks for your great help.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by