Solving nonlinear function using fzero, Error Function values at the interval endpoints must differ in sign.

4 visualizaciones (últimos 30 días)
```
Imp=100;
t0=1e-6;
P=204000000;
Tf=2e-3;
x = fzero( @(x) myfunction(x, t0, Imp, P, Tf), [1.001, 10000]);
function [f] = myfunction( x, t0, Imp, P0, Tf)
f = Imp - (-(P0*t0*(x-1.0)*(x^(-Tf/(t0*(x-1.0)))-1.0))/(log(x)*(x^(-1.0/(x-1.0)) -x^(-x/(x-1.0))))+(P0*t0*(x^(-(Tf*x)/(t0*(x-1.0)))-1.0)*(x-1.0))/(x*log(x)*(x^(-1.0/(x-1.0))-x^(-x/(x-1.0)))));
end
```
x must bigger than 1.0
I don't think these input will make fzero suffer
thank you
  4 comentarios
Walter Roberson
Walter Roberson el 4 de Jun. de 2022
Editada: Walter Roberson el 4 de Jun. de 2022
It is +100 at x=-1 but change x away from -1 and it goes complex, so at the moment I have no evidence that it has a real root.
Sam Chak
Sam Chak el 5 de Jun. de 2022
Once you have found the root of nonlinear function, can you verify if the solution really crosses 0?
Imp = 100;
t0 = 1e-6;
P0 = 204000000;
Tf = 2e-3;
f = @(x) Imp - (-(P0*t0*(x-1.0)*(x^(-Tf/(t0*(x-1.0)))-1.0))/(log(x)*(x^(-1.0/(x-1.0)) -x^(-x/(x-1.0))))+(P0*t0*(x^(-(Tf*x)/(t0*(x-1.0)))-1.0)*(x-1.0))/(x*log(x)*(x^(-1.0/(x-1.0))-x^(-x/(x-1.0)))));

Iniciar sesión para comentar.

Respuestas (1)

Lateef Adewale Kareem
Lateef Adewale Kareem el 4 de Jun. de 2022
Imp=100;
t0=1e-6;
P=204000000;
Tf=2e-3;
x = nan;
options = optimset('Display','off'); % show iterations
x0 = 2;
while(isnan(x))
x = fzero( @(x) myfunction(x, t0, Imp, P, Tf), x0, options);
x0 = x0*1.2;
end
disp(['x = ', num2str(x)])
x = 1.762566874060497e+21
function [f] = myfunction( x, t0, Imp, P0, Tf)
f = Imp - (-(P0*t0*(x-1.0)*(x^(-Tf/(t0*(x-1.0)))-1.0))/(log(x)*(x^(-1.0/(x-1.0)) -x^(-x/(x-1.0))))+(P0*t0*(x^(-(Tf*x)/(t0*(x-1.0)))-1.0)*(x-1.0))/(x*log(x)*(x^(-1.0/(x-1.0))-x^(-x/(x-1.0)))));
end

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by