Please help solve a system of differential equation

1 view (last 30 days)
I have a system of differential equation in x,y with boundary conditions. I want to solve it analytically and numerically. The analytical solutions coming in the form of error functions. Can someone please help me find analytical and numerical solution for this, I have been trying for weeks now, really need to solve this for my thesis. Please help.

Answers (1)

Alan Stevens
Alan Stevens on 15 Mar 2023
Here's a numerical approach:
First manipulate the equations
tspan = [0, 120];
ic = [80000, 0.001];
[t, xy] = ode45(@rate, tspan, ic);
x = xy(:,1); y = xy(:,2);
subplot(2,1,1)
plot(t,x),grid
xlabel('t'), ylabel('x')
subplot(2,1,2)
plot(t,y),grid
xlabel('t'), ylabel('y')
function dxydt = rate(~,xy)
a = 0.1; b = 0.2; c = -0.1; % Replace with desired values
x = xy(1); y = xy(2);
dxydt = [a-b+c*x*y; % eqn (3)
c*y*(1-y) - a*y/x]; % eqn (5)
end
  19 Comments
Jayesh Jawandhia
Jayesh Jawandhia on 4 Apr 2023
Hope you are doing well. I have been reading up on these and your solution has been really helpful. I just had a follow-up. We are trying to find a better fit by making a and b as a function of t. I haven't been able to figure out how do I add these to my ode45 solver in Matlab just like what you did here.
Can you please help with this? For simplicity, I am assuming both a and b second order in t, i.e.:
a = mt^2+nt+r
b = pt^2+qt+s
Really thankful for all your help!
Torsten
Torsten on 4 Apr 2023
What's the problem ?
function dxydt = rate(t,xy);
m = ...;
n = ...;
r = ...;
p = ...;
q = ...;
s = ...;
a = m*t^2+n*t+r;
b = p*t^2+q*t+s;
x = xy(1);
y = xy(2);
dxydt = [a-b+c*x*y;c*y*(1-y)-a*y/x];
end

Sign in to comment.

Categories

Find more on Numerical Integration and Differential Equations 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!