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

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