How to located a point on top, in between and below two curves.

조회 수: 5 (최근 30일)
Paul Kpantey
Paul Kpantey 2020년 4월 2일
댓글: Paul Kpantey 2020년 4월 4일
I need help I have two curves ploted which meets at both ends. I want , when a user enters a point, it should tell the user whether the point entered is above the upper curve or on the upper curve or in between the curves or on the lower curve or below the lower curve. Below is my code;
if true
X = 0 : 20 : 100;
y1 = [ 1085 1160 1230 1310 1380 1453 ];
y2 = [ 1085 1198 1280 1350 1405 1453 ];
plot(x, y1,'r'); % plot lower curve
Hold on;
plot(x, y2, 'b'); %plot upper curve
X = input('enter the value of x: ');
Y = input('enter the value of y: ');
plot (X , Y ,'g'); % user ploted points
end
So all i am saying is that; After the user has entered the X and the Y values and it is ploted , there should be some codes to determine whether the point ploted or entered is above the upper curve or on the upper curve or in between the curves or on the lower curve or below the lower curve . I hope am making sense since am not quite matlab friendly. Please help.
  댓글 수: 2
John D'Errico
John D'Errico 2020년 4월 3일
Do you kow how to use interpolation, for example, interp1? If not, then it is time to learn.
Can you interpolate each curve, at the given x value? How would that tell you if the point is above or below each curve? How will that allow you to answer your question?
Paul Kpantey
Paul Kpantey 2020년 4월 3일
Thanks for the comment.
Ihavent used that function before. will try that.
But at the meantime can you help me ith that algorithm?

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

채택된 답변

the cyclist
the cyclist 2020년 4월 3일
편집: the cyclist 2020년 4월 3일
You should be able to use the inpolygon function to solve this.
  댓글 수: 10
Image Analyst
Image Analyst 2020년 4월 3일
You were going to look into interp1(), remember? So just reverse y and x and use it. Something like (untested)
x1 = interp1(yBlue, xBlue, yGreen);
x2 = interp1(yRed, xRed, yGreen);
Paul Kpantey
Paul Kpantey 2020년 4월 4일
works perfectly @ Image Analyst
Thanks so so much
i did this according to what you stated up
x1 = interp1(y2, x, Y);
x2 = interp1(y1, x, Y);

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by