Please help solve a system of differential equation

1 次查看(过去 30 天)
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.

回答(1 个)

Alan Stevens
Alan Stevens 2023-3-15
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 个评论
Jayesh Jawandhia
Jayesh Jawandhia 2023-4-4
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 2023-4-4
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

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by