How to solve coupled differential equation in a limited range of the variable?

1 次查看(过去 30 天)
I need to solve the following set of coupled equations.(these are not the exact equations,but a similar example)
x'=y+x;
y'=2x+y+p;
where
p = y-7 if y>7
= 0 else
I dont know what type they fall into. I have tried using 'dsolve' but to no avail. Any specific matlab function for this case, or even a link to solving such equations would be greatly appreciated.
Thanks in advance.

采纳的回答

Star Strider
Star Strider 2017-6-10
This seems to work:
y = linspace(0,10);
p = (y-7).*(y>7);
figure(1)
plot(y, p)
grid
% % % MAPPING: x = z(1), y = z(2)
de = @(t,z) [z(2) + z(1); 2*z(1) + z(2) + (z(2)-7).*(z(2)>7)];
ts = [0 10];
[T,Z] = ode15s(de, ts, [0.1; 0]);
figure(2)
semilogy(T, Z)
grid
Numerical ODE solvers tend not to do well with discontinuities. That does not seem to be a problem here, probably because ‘p’ is not a ‘step’ or other abrupt discontinuity.
  4 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by