tanh gives value larger than 1
Show older comments
I'm trying to solve a set of ode with ode45. Parameter alpha_a and alpha_m are defined through a tanh function. Plotting this function gives values way larger than 1 (increasing ad infinitum), while the idea is to set a two-phase parameter that is between 0 and 1 (to estimate growth factors).
The main code is the following:
Y0 = [600; 10; 10; 0.01; 0; 0; 0];
[ts, ys] = ode45(@Pinto1, tspan, Y0); % solves the set of ode's with a general ode solver
function dBdt = Pinto1(t,B)
S = B(1); % substrate concentration
xa = B(2); % anodophilic / electrogens concentration
xm = B(3); % methanogens concentration
Mox = B(4); % oxidised mediator concentration
Q_hold = B(5); % space declaration for Q
alpha_a_hold = B(6);
alpha_m_hold= B(7);
% here are the formulas for S, xa, xm, Mox, Q
alpha_a = (1+tanh(Kx*(xa+xm-Xma)))/2; % biofilm retention fraction for electrogens
alpha_m = (1+tanh(Kx*(xa+xm-Xmm)))/2; % biofilm retention fraction for methanogens
dxadt = mua*xa - Kda*xa - alpha_a*D*xa; % electrogens concentration difference over time
dxmdt = mum*xm - Kdm*xm - alpha_m*D*xm; % methanogens concentration difference over time
% mua, Kda, mum, Kdm, and D are constants or variables defined unrelated to alpha_a and alpha_m.
dBdt = [dSdt; dxadt; dxmdt; dMoxdt; Q; alpha_a; alpha_m];
end
The calculation of S, Mox, and Q are unrelated to alpha_a and alpha_m.
My output vector contains alpha_a and alpha_m values of well over 3 within the part that I'm plotting.
As far as I know, tanh should have output values between -1 and 1.
Am I declaring my input and output wrong? Or is tanh not suited for use in an ode system? I cannot recreate the issue with just constants (leaving out xa and xm)
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!