How to solve an ODE using ODE45

3 次查看(过去 30 天)
Christian Bellew
Christian Bellew 2020-10-19
编辑: Alan Stevens 2020-10-19
I am trying to write a script to explain the effects HIV-1 has on a cell. Also I need to plot the results. The equation and code is attached. Any help would be greatly appreciated.
function Rw = rhs(t,z,par)
% Right-hand side of differential equations
% par: Parameter struct
% Unpack vector of dependent variables:
d = z(1);
lambda = z(2);
beta = z(3);
a = z(4);
alpha = z(5);
b=z(6);
k=z(7);
u=z(8);
c=z(9);
q=z(10);
Rw = (((alpha*c)/(b*q))*((lambda/a)-((d*u)/(beta*k)))) %ODE
par.d = 0.01; %death rate of HIV-1 cell
par.lambda = 2; %production rate of host cell (cell/mm^3)
par.beta = 0.004; %infection rate of host cell by HIV-1 (mm^3/virus)
par.a = 0.33; %death rate of HIV-1 cell
par.alpha = 0.004; %infection rate by recombinant (mm^3/virus)
par.b = 2; %death rate of double infected cell
par.k = 50; %HIV-1 production rate by a cell (virus/cell)
par.u = 2; %removal rate of HIV-1
par.c = 2000; %production rate of recombinant by a double infected cell (virus/cell)
par.q = 2; %removal rate of recmbinant
end
%***************This is the framework my teacher provided us, it just doesn't seem to work with my equation**************
%This is the Matlab code to solve differential equations. It consists of
%two functions: one is the function which inputs the differential
%equation by providing the derivatives of the variables; the other is the
%main function which implements the ODE45 solver to approximate solutions
%for the IVP below.
%dy/dx=F(x,y),
%y(x0)=y0.
%The other is the function that provides the equation(s)
function [X,Y]=Mat285a %This is the name under which
%the function will be available
%after we save this as a .m file.
x0=0; xT=0.5;
xspan=[x0, xT]; %interval of independent variable (domain)
options = odeset('RelTol',1e-8,'AbsTol',[1e-8]); %options chosen
y0=1; %initial value
[X,Y] = ode45(@firstode,xspan,y0,options); %use ode45 to solve differential equations
figure(1)
hold on
plot(X,Y,'r') %plot the solution curve.
function dy=firstode(x,y)
%compute the derivative dy/dx=x*y^2+y.
%dy=x*y^2+y
Rw=(((alpha*c)/(b*q))*((lambda/a)-((d*u)/(beta*k)))) %ODE
  3 个评论
Christian Bellew
Christian Bellew 2020-10-19
That's exactly what I was thinking, I just wasn't sure. We were given a research paper with many equations describing the actions of the virus. The problem is none of them look like differential equations. I guess I'll just try to pick another equation?
Alan Stevens
Alan Stevens 2020-10-19
编辑:Alan Stevens 2020-10-19
Since you have 10 dependent variables (d, lambda, etc) you should have 10 ode's (though they might be combined into a single matrix equation). You should also have 10 intial conditions.(assuming the ode's are all first order).
Are you sure all those parameters (d, lambda, etc) are dependent variables? If they are then you will need 10 odes. However, they look suspiciously like the names given to constants, in which case there might well be fewer odes involved!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by