Error using vertcat Dimensions of arrays being concatenated are not consistent. For solving ODE

1 view (last 30 days)
I was trying to solve the ODE, but I have checked several times it showed 'error using vertcat' . Could anyone help me ?
tspan = [0 60];
%Initial Value
C_V0 = 0 %x(1)
C_I0 = 0 %x(2)
C_C0 = 2 %x(3)
C_W0 = 0 %x(4)
C_G0 = 0 %x(5)
[t,x] = ode45(@dxdt ,tspan , [C_V0, C_I0, C_C0, C_W0, C_G0]);
plot(t,x)
legend('Tissue Vasculature','IF+ECM','Central','Cytosol','Fat Globules')
xlabel(' time')
ylabel('Concentration')
function AllProcess = dxdt (t,x)
Q_CV = 14.85 % (L/hr ) Perfusion of plasma from central to vasculature
Q_VI = 0.033 % (L/hr ) Perfusin from vasulature to IF+ECM
Q_IV = 0.165 % (L/hr ) Perfusion from IF+ECM to vasculature
kD = 0.3 % (L/hr ) Diffusive MT constant between vasculature and IF+ECM
kD1 = 0.666 % (L/hr ) Diffusive MT constant between cytosol and IF+ECM
kD2 = 3.33 % (L/hr ) Diffusive MT constant between cytosol and fat globules
V_C = 60 % (L) Volume of Central
V_V = 0.5 % (L) Volume of Vasculature
V_I = 1.5 % (L) Volume of IF+ECM
V_W = 1.3% (L) Volume of Cytosol
V_G = 11.7 % (L) Volume of fat globules
thalf = 20 % (hr) half life of drug
ke = 0.693/thalf
P_ow = 10 % Oil Water Partition Coefficient
f_C = 0.5 % unbound drug in central compartment
f_V = 0.5 % unbound drug in Vasulature
f_I = 0.5 % unbound drug in IF+ECM
f_B = 0.5 % unbound drug in IF boundary ???
f_W = 0.5 % unbound drug in Cytosol
f_G = 1 % unbound drug in fat globules, no proteins in fat globules
AllProcess = [Q_CV/V_V*(f_C*x(3) - f_V*x(1)) + Q_IV/V_V*(f_I*x(2)-f_V*x(1)) - kD/V_V*(P_ow*f_V*x(1)-P_ow*f_I*x(2)); %x(1) Vasculature
kD*P_ow/V_I *(f_V * x(1) - f_I*x(2)) + Q_VI/V_I *(f_V *x(1) - f_I * x(2) ) - Q_IV/V_I * (f_I* x(2) - f_C * x(3)) - kD1*P_ow/V_I *(f_I * x(2) - f_B*x(4)); % IF + ECM
(Q_VI - Q_IV )/V_C *f_I * x(2) -Q_CV /V_C * f_C * x(3) + (Q_CV + Q_IV - Q_VI)/V_C *f_V * x(1) - ke * f_C*x(3); % Central
kD1*P_ow/V_W *(f_I *x(2) - f_W*x(4)) - kD2/V_W * (P_ow * f_W * x(4) - f_G*x(5)); % Cytosol
kD2/V_G*(P_ow*f_W*x(4) - f_G *x(5))] ;% Globules
end

Accepted Answer

Stephan
Stephan on 3 Jun 2020
tspan = [0 60];
%Initial Value
C_V0 = 0; %x(1)
C_I0 = 0; %x(2)
C_C0 = 2; %x(3)
C_W0 = 0; %x(4)
C_G0 = 0; %x(5)
[t,x] = ode45(@dxdt ,tspan , [C_V0, C_I0, C_C0, C_W0, C_G0]);
plot(t,x)
legend('Tissue Vasculature','IF+ECM','Central','Cytosol','Fat Globules')
xlabel(' time')
ylabel('Concentration')
function AllProcess = dxdt (~,x)
Q_CV = 14.85; % (L/hr ) Perfusion of plasma from central to vasculature
Q_VI = 0.033; % (L/hr ) Perfusin from vasulature to IF+ECM
Q_IV = 0.165; % (L/hr ) Perfusion from IF+ECM to vasculature
kD = 0.3; % (L/hr ) Diffusive MT constant between vasculature and IF+ECM
kD1 = 0.666; % (L/hr ) Diffusive MT constant between cytosol and IF+ECM
kD2 = 3.33; % (L/hr ) Diffusive MT constant between cytosol and fat globules
V_C = 60; % (L) Volume of Central
V_V = 0.5; % (L) Volume of Vasculature
V_I = 1.5; % (L) Volume of IF+ECM
V_W = 1.3; % (L) Volume of Cytosol
V_G = 11.7; % (L) Volume of fat globules
thalf = 20; % (hr) half life of drug
ke = 0.693/thalf;
P_ow = 10; % Oil Water Partition Coefficient
f_C = 0.5; % unbound drug in central compartment
f_V = 0.5; % unbound drug in Vasulature
f_I = 0.5; % unbound drug in IF+ECM
f_B = 0.5; % unbound drug in IF boundary ???
f_W = 0.5; % unbound drug in Cytosol
f_G = 1; % unbound drug in fat globules, no proteins in fat globules
AllProcess = zeros(numel(x),1);
AllProcess(1) = Q_CV/V_V*(f_C*x(3) - f_V*x(1)) + Q_IV/V_V*(f_I*x(2)-f_V*x(1))...
- kD/V_V*(P_ow*f_V*x(1)-P_ow*f_I*x(2)); %x(1) Vasculature
AllProcess(2) = kD*P_ow/V_I *(f_V * x(1) - f_I*x(2)) + Q_VI/V_I *(f_V *x(1)...
- f_I * x(2) ) - Q_IV/V_I * (f_I* x(2) - f_C * x(3))...
- kD1*P_ow/V_I *(f_I * x(2) - f_B*x(4)); % IF + ECM
AllProcess(3) = (Q_VI - Q_IV )/V_C *f_I * x(2) -Q_CV /V_C * f_C * x(3)...
+ (Q_CV + Q_IV - Q_VI)/V_C *f_V * x(1) - ke * f_C*x(3); % Central
AllProcess(4) = kD1*P_ow/V_W *(f_I *x(2) - f_W*x(4))...
- kD2/V_W * (P_ow * f_W * x(4) - f_G*x(5)); % Cytosol
AllProcess(5) = kD2/V_G*(P_ow*f_W*x(4) - f_G *x(5));% Globules
end

More Answers (0)

Categories

Find more on Chemistry in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!