Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Star Strider
Star Strider le 10 Juin 2017
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 commentaires
Chinmay Sharma
Chinmay Sharma le 18 Juin 2017
Thanks again! Good to know.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by