Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

Star Strider
Star Strider il 10 Giu 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 Commenti

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by