Error: Assignment has more non-singleton rhs dimensions than non-singleton subscripts
9 views (last 30 days)
Show older comments
Hi, i am trying to run a multi compartment model and I keep getting an error. I'm not sure what to do Error I keep getting:
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Here is my code:
clear all; close all; clc;
syms Cp(t) Cb(t) Ce(t) Cc(t) Cf(t)
t = [0 30];
Vb=5; %average blood volume (L)
k1 = exp(-0.1*t);
k23 = 33;
k32 = 20;
Ve = 14;
k34 = 33;
k43=20;
k5 = 50;
Vp = 1.37e-3;
Vc = 50e-6;
Vf = Vc;
ode1 = diff(Cp) == (-k1*Cp)/Vp;
ode2 = diff(Cb) == (k1*Cp-k23*Cb+k32*Ce)/Vb;
ode3 = diff(Ce) == (k23*Cb+k43*Cc-k32*Ce-k34*Ce)/Ve;
ode4 = diff(Cc) == (k32*Ce-k43*Cc-k5*Cc)/Vc;
ode5 = diff(Cf) == (k5*Cc)/Vf;
odes = [ode1; ode2; ode3; ode4; ode5]
S = dsolve(odes)
CpSol(t) = S.Cp
CbSol(t) = S.Cb
CeSol(t) = S.Ce
CcSol(t) = S.Cc
CfSol(t) = S.Cf
cond1 = Cp(0) == 100;
cond2 = Cb(0) == 0;
cond3 = Ce(0) == 0;
cond4 = Cc(0) == 0;
cond5 = Cf(0) == 0;
conds = [cond1; cond2; cond3; cond4; cond5];
[CpSol(t), CbSol(t), CeSol(t), CcSol(t), CfSol(t)] = dsolve(odes,conds)
fplot(CpSol)
hold on
fplot(CbSol)
hold on
fplot(CeSol)
hold on
fplot(CcSol)
hold on
fplot(CfSol)
grid on
legend('CpSol','CbSol','CeSol','CcSol','CfSol','Location','best')
0 Comments
Answers (0)
See Also
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!