Finding the intersection of a line and a parabola numerically

조회 수: 13 (최근 30일)
Luis Canales Tough
Luis Canales Tough 2016년 4월 20일
댓글: Image Analyst 2016년 4월 21일
hello, I have come to a stall when trying to figure out how to obtain the two elements that meet a single condition. So if I have a parabolic function and a line(condition) going through it at two different points, how can I obtain the two numerical values for those points?
This is where I am stuck:
dd=logspace(-9,1,100);
uu=sqrt(A_n*(sig_cal*g*dd(1,:)+gamma./(1.225*dd(1,:))));
u2=dd+v_dw_ms;
plot(dd,uu,'r',dd,u2,'b')
where v_dw_ms is a certain constant value on the uu axis.
I can obtain the points graphically, but I need the actual numerical values for further numerical analysis.
Thanks in advance.

채택된 답변

Image Analyst
Image Analyst 2016년 4월 20일
Just set the line and parabola equal to each other and solve for x
yParabola = a*x^2 + b*x + c
yLine = m*x+d
a*x^2 + b*x + c = m*x + d
a*x^2 + (b-m)*x + (c-d) = 0
Then use the quadratic solution formula to solve for the 2 x:
x1 = (-(b-m)-sqrt((b-m)^2-4*a*(c-d))) / (2*a)
x2 = (-(b-m)+sqrt((b-m)^2-4*a*(c-d))) / (2*a)
  댓글 수: 2
Luis Canales Tough
Luis Canales Tough 2016년 4월 20일
That would work, but I think I made an error saying parabolic function, simply because the graph looks similar to a parabola.
The equation is actually of the form Y=sqrt(X + 1/X), so the quadratic formula does not apply.
Image Analyst
Image Analyst 2016년 4월 21일
So simply set them equal like I said and then simplify the equation. I think you can then use roots() or fsolve() or something.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by