Length of a plotted line

조회 수: 6 (최근 30일)
Frederik Reese
Frederik Reese 2022년 6월 7일
댓글: Frederik Reese 2022년 6월 7일
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에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by