필터 지우기
필터 지우기

find coordinate(-s) on a plot

조회 수: 3 (최근 30일)
ARGY B
ARGY B 2019년 9월 7일
댓글: darova 2019년 9월 10일
coord.PNG
I have the plot you see above (plotted from data of two vectros X and Y). And I would like to find the coordinates x where y =10. Usually if the y value appears only one time, then I can use the interp1 function.
But what about when this y value belongs to 2 or more x coordinates?
  댓글 수: 2
dpb
dpb 2019년 9월 7일
Look for crossing the threshold -- hint: what happens in sign(diff(y)-threshold) when the crossing is rising or falling?
darova
darova 2019년 9월 7일
I like polyxpoly() function of intersections from fileexchange

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

답변 (1개)

Nishant Gupta
Nishant Gupta 2019년 9월 10일
Hi Argy,
You can use logical indexing to find the x-ordinates corresponding to y = 10 as follows:
x = [1 2 3 4 5]; % x vector
y = [15 10 25 10 5]; % y vector
plot(x,y);
hold on;
yline(10); % plot horizontal line at y = 10
idx = find(y==10);
for i = 1:numel(idx)
xline(x(idx(i))); % to get vertical line at all x-ordinates corresponding to y = 10
end
hold off;
  댓글 수: 1
darova
darova 2019년 9월 10일
What if there is no y=10 (y=10.1)

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

카테고리

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