How can I find roots of my interpolated functions?

조회 수: 3 (최근 30일)
Moj
Moj 2014년 12월 12일
댓글: Moj 2014년 12월 12일
Dear community,
I want to use 'fzero' to find the root of my equation. but unfortunately it doesn't work. it gives me this error:
Error using fzero (line 169) FUN must be a function, a valid string expression, or an inline function object
Error in anchoring (line 49) x = fzero(fun,x0)
The related part of my MATLAB code is:
theta_00 = 0:1e-6:3.5;
y_1 = interp1(theta_0, dtheta,theta_00, 'spline');
y_2 = interp1(theta_0, dtheta, theta_00, 'spline');
fun = y_1 - y_2;
x0 = [0 3.5];
x = fzero(fun,x0)
y_1 is belongs to some experimental data but y_2 has a function. I interpolate both of them. Here I do not know why am I getting this error. how can I find these crossing point?
Thanks

답변 (1개)

Moj
Moj 2014년 12월 12일
yes I modified it as a
fun = @(theta_0)(y_1 - y_2);
but it still doesn't work I get this error:
Error using fzero (line 274) The function values at the interval endpoints must differ in sign
by looking at the figure it is clear that the fun has opposite sign at first and final point. by the way I examine a smaller interval but it again has the same error.
how can I solve this?
  댓글 수: 2
Mohammad Abouali
Mohammad Abouali 2014년 12월 12일
1) Don't comment to with new answer. There is "Comment on this Answer" button that you can use.
2) check the comment that below the answer that I provided to see what is going wrong.
Moj
Moj 2014년 12월 12일
sorry sir, I know this, but I just made a mistake.
thanks

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by