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

6 Ansichten (letzte 30 Tage)
```
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 Kommentare
Walter Roberson
Walter Roberson am 4 Jun. 2022
Bearbeitet: Walter Roberson am 4 Jun. 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 am 5 Jun. 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)))));

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Lateef Adewale Kareem
Lateef Adewale Kareem am 4 Jun. 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

Kategorien

Mehr zu Optimization finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by