简体   繁体   English

检查给定点(x,y)是否低于或高于曲线

[英]Checking if a given point(x,y) is below or above a curve

I have a task to solve using Matlab.我有一个任务要使用 Matlab 解决。 I have two curves generated with 'fit' functions in matlab.我在 matlab 中用“拟合”函数生成了两条曲线。 their equations are as follows:它们的方程如下:

fo =福 =

 Linear model Poly2:
   fo(x) = p1*x^2 + p2*x + p3
 Coefficients (with 95% confidence bounds):
   p1 =   -0.005234  (-0.007191, -0.003278)
   p2 =      0.8276  (0.537, 1.118)
   p3 =       39.62  (30.59, 48.65)

fu =福 =

 Linear model Poly2:
   fu(x) = p1*x^2 + p2*x + p3
 Coefficients (with 95% confidence bounds):
   p1 =   -0.004092  (-0.01098, 0.002796)
   p2 =       0.856  (-0.1671, 1.879)
   p3 =       14.73  (-17.06, 46.53)

My task is to check if any given point (x,y) is either below the curve fu or above the curve fo.我的任务是检查任何给定的点 (x,y) 是否低于曲线 fu 或高于曲线 fo。 (ideally the point(x,y) should be between these curves for the next process to begin.) (理想情况下,点(x,y)应该在这些曲线之间,以便开始下一个过程。)

How do i approach??我该如何接近??

something like就像是

% your data
xm=1;
ym=5;

if ym<fu(xm) & ym>fo(xm)
   % good!
else
  % bad :(
end

? ?

For any given equation, any order , Say对于任何给定的方程,任何顺序,说

Y= a1x2 + b1x + c1, You can write, Y-(a1x2 +b1x +c1) = 0 Let this be y - f(x) = 0 Y= a1x2 + b1x + c1,你可以写,Y-(a1x2 +b1x +c1) = 0 令其为 y - f(x) = 0

And let your point be (x',y') If y' - f(x') > 0, your point lies outside the curve and if this is < 0 it is inside.并让您的点为 (x',y') 如果 y' - f(x') > 0,则您的点位于曲线之外,如果它 < 0,则它位于曲线内部。

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM