Error using odearguments (line 113) Inputs must be floats, namely single or double.

2 visualizaciones (últimos 30 días)
clear;clc;close all;
syms t
k1 = 2196595622168743217/1130684981446705152 - (27270095640660425*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(6030319901049094144*(99*exp(-(3*t)/40) + 1)) - (3272411476879251*(5/(359*exp(-(2*t)/25) + 1) - 1))/(376894993815568384*(359*exp(-(2*t)/25) + 1)) - (53449387455694433*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(2826712453616762880*(99999*exp(-(7*t)/50) + 1)) - (1090803825626417*(5/(39*exp(-(2*t)/25) + 1) - 1))/(1130684981446705152*(39*exp(-(2*t)/25) + 1))
k2 = -((204350833091936256*exp(-(3*t)/40))/14621315237439125 + 6192449487634432/43863945712317375)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1))), (135*exp(-(3*t)/40)*((1089*exp(-(3*t)/40))/25 + 11/25))/(8*(99*exp(-(3*t)/40) + 1)^2) - ((204350833091936256*exp(-(3*t)/40))/14621315237439125 + 6192449487634432/43863945712317375)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))
k3 = (4573562550968941875*((808396133113004032*exp(-(2*t)/25))/28660319845255881 + 2251799813685248/28660319845255881))/(36893488147419103232*(359*exp(-(2*t)/25) + 1)) - ((808396133113004032*exp(-(2*t)/25))/28660319845255881 + 2251799813685248/28660319845255881)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1))), (4573562550968941875*((808396133113004032*exp(-(2*t)/25))/28660319845255881 + 2251799813685248/28660319845255881))/(36893488147419103232*(359*exp(-(2*t)/25) + 1)) - ((808396133113004032*exp(-(2*t)/25))/28660319845255881 + 2251799813685248/28660319845255881)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1))) + (3231*exp(-(2*t)/25)*((1436*exp(-(2*t)/25))/9 + 4/9))/(50*(359*exp(-(2*t)/25) + 1)^2)
k4a = -(1500*((87820192733724672*exp(-(2*t)/25))/3184479982806209 + 2251799813685248/3184479982806209))/(((9007199254740992*2^(1/2)*13139^(1/2)*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(39*exp(-(2*t)/25) + 1))/(326392588619071785*((14987979559889010688*exp(-(2*t)/25))/4984107436090777 + 1152921504606846976/14952322308272331)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))) - 825167718535963/140737488355328)*(39*exp(-(2*t)/25) + 1)), (39*exp(-(2*t)/25)*(156*exp(-(2*t)/25) + 4))/(50*(39*exp(-(2*t)/25) + 1)^2) - (1500*((87820192733724672*exp(-(2*t)/25))/3184479982806209 + 2251799813685248/3184479982806209))/(((9007199254740992*2^(1/2)*13139^(1/2)*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(39*exp(-(2*t)/25) + 1))/(326392588619071785*((14987979559889010688*exp(-(2*t)/25))/4984107436090777 + 1152921504606846976/14952322308272331)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))) - 825167718535963/140737488355328)*(39*exp(-(2*t)/25) + 1))
k4b = -(1120*((234560134967407411200*exp(-(7*t)/50))/14072776651639139 + 7036874417766400/42218329954917417))/(((9007199254740992*2^(1/2)*13139^(1/2)*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(39*exp(-(2*t)/25) + 1))/(326392588619071785*((14987979559889010688*exp(-(2*t)/25))/4984107436090777 + 1152921504606846976/14952322308272331)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))) - 825167718535963/140737488355328)*(99999*exp(-(7*t)/50) + 1)), (9799902*exp(-(7*t)/50)*((2499975*exp(-(7*t)/50))/28 + 25/28))/(625*(99999*exp(-(7*t)/50) + 1)^2) - (1120*((234560134967407411200*exp(-(7*t)/50))/14072776651639139 + 7036874417766400/42218329954917417))/(((9007199254740992*2^(1/2)*13139^(1/2)*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(39*exp(-(2*t)/25) + 1))/(326392588619071785*((14987979559889010688*exp(-(2*t)/25))/4984107436090777 + 1152921504606846976/14952322308272331)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))) - 825167718535963/140737488355328)*(99999*exp(-(7*t)/50) + 1))
k12 = -((1089*exp(-(3*t)/40))/25 + 11/25)*((1090803825626417*(5/(39*exp(-(2*t)/25) + 1) - 1))/(1125899906842624*(39*exp(-(2*t)/25) + 1)) + (81810286921981275*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(18014398509481984*(99*exp(-(3*t)/40) + 1)) + (9817234430637753*(5/(359*exp(-(2*t)/25) + 1) - 1))/(1125899906842624*(359*exp(-(2*t)/25) + 1)) + (53449387455694433*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(2814749767106560*(99999*exp(-(7*t)/50) + 1)))
k23 = -((808396133113004032*exp(-(2*t)/25))/15791020456434255 + 2251799813685248/15791020456434255)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))
k34a = -(3*((87820192733724672*exp(-(2*t)/25))/3184479982806209 + 2251799813685248/3184479982806209)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1))))/(2*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(39*exp(-(2*t)/25) + 1))
k34b = -((351840202451111116800*exp(-(7*t)/50))/22291359879643463 + 3518437208883200/22291359879643463)*((98*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(125*(99999*exp(-(7*t)/50) + 1)) + (28*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1))))/(25*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(99999*exp(-(7*t)/50) + 1)))
b1 = 7.8231e-05
b2 = 0
b3 = (7317700081550307*((25868676259616129024*exp(-(2*t)/25))/65278517723814357 + 72057594037927936/65278517723814357))/(649325391394576216883200*(359*exp(-(2*t)/25) + 1)) + (486*((1436*exp(-(2*t)/25))/9 + 4/9))/(1375*(359*exp(-(2*t)/25) + 1))
b4a = (162*(156*exp(-(2*t)/25) + 4))/(1375*(39*exp(-(2*t)/25) + 1)) - (3*((936748722493063168*exp(-(2*t)/25))/2417722878659791 + 72057594037927936/7253168635979373))/(22000*((9007199254740992*2^(1/2)*13139^(1/2)*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(39*exp(-(2*t)/25) + 1))/(326392588619071785*((14987979559889010688*exp(-(2*t)/25))/4984107436090777 + 1152921504606846976/14952322308272331)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))) - 825167718535963/140737488355328)*(39*exp(-(2*t)/25) + 1))
b4b = (3024*((2499975*exp(-(7*t)/50))/28 + 25/28))/(34375*(99999*exp(-(7*t)/50) + 1)) - (7*((13848568854164275200*exp(-(7*t)/50))/62450406459847 + 112589990684262400/50772180451855611))/(68750*((9007199254740992*2^(1/2)*13139^(1/2)*(3/(2*(39*exp(-(2*t)/25) + 1)) + 28/(25*(99999*exp(-(7*t)/50) + 1)))*(39*exp(-(2*t)/25) + 1))/(326392588619071785*((14987979559889010688*exp(-(2*t)/25))/4984107436090777 + 1152921504606846976/14952322308272331)*((2*(5/(39*exp(-(2*t)/25) + 1) - 1))/(39*exp(-(2*t)/25) + 1) + (75*(100/(11*(99*exp(-(3*t)/40) + 1)) - 1))/(8*(99*exp(-(3*t)/40) + 1)) + (18*(5/(359*exp(-(2*t)/25) + 1) - 1))/(359*exp(-(2*t)/25) + 1) + (196*(2/(99999*exp(-(7*t)/50) + 1) - 1))/(5*(99999*exp(-(7*t)/50) + 1)))) - 825167718535963/140737488355328)*(99999*exp(-(7*t)/50) + 1))
C_Soil_initial = 1;
C_Roots_initial = 0;
C_Stem_initial = 0;
C_Leaves_initial = 0;
C_Fruits_initial = 0;
solver = @(t,C)[-k1 * C(1) + b1; -k2 * C(2) + k12 * C(1) + b2; -k3 * C(3) + k23 * C(2) + b3; -k4a * C(4) + k34a * C(3) + b4a; -k4b * C(5) + k34b * C(3) + b4b];
initialconcentrations = [C_Soil_initial C_Roots_initial C_Stem_initial C_Leaves_initial C_Fruits_initial];
tol = 1e-13; % tolerance
options = odeset ('RelTol', tol,'AbsTol',[tol tol tol tol tol], 'NonNegative',1, 'NonNegative',2);
[t,C] = ode15s (solver, [0 5], initialconcentrations,options);
plot(t,C(:,1)); hold on
plot(t,C(:,2)); hold on
plot(t,C(:,3)); hold on
plot(t,C(:,4)); hold on
plot(t,C(:,5)); hold on
legend('Soil','Roots','Stem','Leaves','Fruits')

Respuestas (2)

William Rose
William Rose el 14 de Abr. de 2021
I recommend that you remove the syms command at the top of your code.
You have defined a bunch of constants in terms of t, and t is symbolic. I think you need to define constants as actual constants and then use those constants, and the variable t (which should not be symbolic), inside function solver, which you have defined and which is calculating the derivatives.

Walter Roberson
Walter Roberson el 14 de Abr. de 2021
You need to use matlabFunction() to turn your symbolic expressions into numeric code. Be sure to use the 'vars' option to control the order of the input variables.

Categorías

Más información sobre Ordinary Differential Equations 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