Error message solving nonlinear equation with Matlab

169 Views Asked by At

I have attempted to solve for the variable $ky$ in the following equation:

$$\frac{Yu}{Yt} = \left({\frac{k’x}{k’x-ky} \text{exp}(-ky \cdot t) - \frac{ky}{k’x-ky} \text{exp}(-k’x \cdot t)}\right)\left(1–D\right) + D$$

The values used for the variables are: $D = 0.2$, $Yu/Yt = 0.5940$, $t = 3$, and $k’x = 0.0087$.

The following code was written for Matlab in order to solve the ecuation for $ky$:

Yut = 0.5940; % Yu/Yt
K = 0.0087;   % Kx
t = 3;        % tiempo en h
D = 0.2;      % Valor entre 0 - 1

fun = @(x)(1-D)*( (K/(K-x))*exp(-t*x) - (x/(K-x))*exp(-K*t) )+ D-Yut; % function 
x0 = [0,1000];                        % initial interval
options = optimset('Display','iter'); % show iterations
[x,fval,exitflag,output] = fzero(fun,x0,options)

Matlab is displaying the following error message when values for $kx < 0.2222$ and $t < 6$ are used in the calculations:

"Error using fzero (line 290). The function values at the interval endpoints must differ in sign"