I keep getting a "Struct contents reference from a non-struct array object" error within my code and cannot get it to run correctly. I am trying to run 2 differential equations at once using ode function.

k=2; %Maximum specific substrate utilization rate (hr^-1)
Ks=80; %Half velocity coefficient (mg/L)
Y=0.4; %biomass true yield coefficient(mg_biomass/mg_substrate_utilized)
b=0.04/24; %specific biomass decay coefficient (hr^-1)
t=[0:840]; %time span 0<t<840 min
syms s(t) Xa(t)
ode1 = diff(s) == ((-k*Xa*s)/(Ks+s));
ode2 = diff(Xa) == (((Y*k*Xa*s)/(Ks+s))-b*Xa);
odes = [ode1; ode2];
S = dsolve(odes);
sSol(t) = S.s;
XaSol(t) = S.Xa;
cond1 = s(0) == 100;
cond2 = Xa(0) == 200;
conds = [cond1; cond2];
[sSol(t), XaSol(t)] = dsolve(odes,conds);

Answers (1)

tgm33518 - I'm guessing that the error is being generated for
sSol(t) = S.s;
(and probably will for the subsequent line too). According to dsolve output arg S, S is a symbolic expression or vector of symbolic expressions, and your code is treating S as if it were a struct.
Why do you think that you can access s and XA in this manner?

Categories

Find more on Programming in Help Center and File Exchange

Tags

Asked:

on 17 Feb 2018

Answered:

on 17 Feb 2018

Community Treasure Hunt

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

Start Hunting!