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

2 visualizaciones (últimos 30 días)
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 comentarios
John D'Errico
John D'Errico el 3 de Abr. de 2020
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 el 3 de Abr. de 2020
Thanks for the comment.
Ihavent used that function before. will try that.
But at the meantime can you help me ith that algorithm?

Iniciar sesión para comentar.

Respuesta aceptada

the cyclist
the cyclist el 3 de Abr. de 2020
Editada: the cyclist el 3 de Abr. de 2020
You should be able to use the inpolygon function to solve this.
  10 comentarios
Image Analyst
Image Analyst el 3 de Abr. de 2020
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 el 4 de Abr. de 2020
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);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by