MATLAB Answers

0

Error in simulation using ODE15s (probably with vertcat)

Asked by Utkarsh Gupta on 13 Oct 2019
Latest activity Edited by Stephan
on 13 Oct 2019
function template
%set the parameters
p = set_parameters;
%set the initial conditions
input.Conc= [100
0
0];%target virus infected
%set simulation time
input.simtime=500;
%simulate
[T, Y] = simulate(p,input);
disp(T)
figure
subplot(1,3,1);plot(T,Y(:,1));title('targets')
subplot(1,3,2);plot(T,(Y(:,2)));title('virions')
subplot(1,3,3);plot(T,Y(:,3));title('infected')
%plot etc.
%%
function p = set_parameters
%==================Parameters=========================
p.kL=.03;
p.kI=.36;
p.kT=.055;
p.kDeg=.12;
p.ikkActivity=.01;
%%
function [T,Y] = simulate(p,input)
y0 = input.Conc;
T = 0:1:input.simtime;
% solve the problem using ode15s
[T,Y] = ode15s(@f,T,y0,[],p,input);
% ODE function
function [dydt]=f(t,y,p,input)
%==============================States=================================
NFkappaB=y(1); IKappaB=y(2); NFI=y(3);
%==============================ODEs===================================
dydt=[ -(p.kL*NFkappaB*IKappaB) + p.kI*p.ikkActivity*NFI
-(p.kL*NFkappaB*IKappaB) + p.kT*NFkappaB -p.kDeg*IKappaB
-(p.kI*p.ikkActivity*NFI)+ p.kL*NFkappaB*IKappaB
];
The above code is giving the following errors:
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
Error in template>f (line 50)
dydt=[ -(p.kL*NFkappaB*IKappaB) + p.kI*p.ikkActivity*NFI
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in template>simulate (line 43)
[T,Y] = ode15s(@f,T,y0,[],p,input);
Error in template (line 12)
[T, Y] = simulate(p,input);

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by Stephan
on 13 Oct 2019
Edited by Stephan
on 13 Oct 2019

function template
%set the parameters
p = set_parameters;
%set the initial conditions
input.Conc= [100 0 0];%target virus infected
%set simulation time
input.simtime=500;
%simulate
[T, Y] = simulate(p,input);
disp(T)
figure
subplot(1,3,1);plot(T,Y(:,1));title('targets')
subplot(1,3,2);plot(T,(Y(:,2)));title('virions')
subplot(1,3,3);plot(T,Y(:,3));title('infected')
%plot etc.
function p = set_parameters
%==================Parameters=========================
p.kL=.03;
p.kI=.36;
p.kT=.055;
p.kDeg=.12;
p.ikkActivity=.01;
function [T,Y] = simulate(p,input)
y0 = input.Conc;
T = 0:1:input.simtime;
% solve the problem using ode15s
[T,Y] = ode15s(@f,T,y0,[],p,input);
% ODE function
function [dydt]=f(t,y,p,input)
%==============================States=================================
NFkappaB=y(1); IKappaB=y(2); NFI=y(3);
%==============================ODEs===================================
dydt=zeros(3,1);
dydt(1)=-(p.kL*NFkappaB*IKappaB) + p.kI*p.ikkActivity*NFI;
dydt(2)=-(p.kL*NFkappaB*IKappaB) + p.kT*NFkappaB -p.kDeg*IKappaB;
dydt(3)=-(p.kI*p.ikkActivity*NFI)+ p.kL*NFkappaB*IKappaB;

  0 Comments

Sign in to comment.