How can I find roots of my interpolated functions?

1 visualización (últimos 30 días)
Moj
Moj el 12 de Dic. de 2014
Comentada: Moj el 12 de Dic. de 2014
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

Respuestas (1)

Moj
Moj el 12 de Dic. de 2014
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 comentarios
Mohammad Abouali
Mohammad Abouali el 12 de Dic. de 2014
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 el 12 de Dic. de 2014
sorry sir, I know this, but I just made a mistake.
thanks

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by