How can I find roots of my interpolated functions?

1 回表示 (過去 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 Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by