필터 지우기
필터 지우기

How to display arc length of the line created on a line plot based on the input data

조회 수: 5 (최근 30일)
Hi,
I am currently plotting a series of x and y co-ordinates using the plot(x,y) function in MATLAB which outputs a graph that looks something like this:
How do I go about displaying the arc length of the line created at points along the line assuming my first x and y data point is 0% and my last data point is 100%?
  댓글 수: 2
Adam Danz
Adam Danz 2022년 1월 17일
The goal isn't quite clear. Is "arc length" some segment of the semi-circular area or are you asking for the entire length of the black line?
jessupj
jessupj 2022년 1월 17일
편집: jessupj 2022년 1월 17일
i think you want something along the lines of the cumulative sum of the pythagorean distances between successive points on the curve, normalized by the final term.

댓글을 달려면 로그인하십시오.

채택된 답변

Voss
Voss 2022년 1월 17일
% some x and y:
x = [10:-1:2 2:10];
y = [5+sqrt(x(1:end/2)) 5-sqrt(x(end/2+1:end))];
plot(x,y,'-o');
set(gca(),'XLim',[0 12]);
% calculate "normalized arc length":
dx = diff(x);
dy = diff(y);
ds = sqrt(dx.^2+dy.^2);
s = cumsum([0 ds]);
s = s/s(end);
% put a text at each x,y with value of s:
v_a = {'top','bottom'};
nx = numel(x);
for i = 1:nx
text(x(i),y(i),sprintf('%d%%',round(100*s(i))),'VerticalAlignment',v_a{1+(i>nx/2)});
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by