フィルターのクリア

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 件のコメント
Chinmay Sharma
Chinmay Sharma 2017 年 6 月 18 日
Thanks again! Good to know.
Star Strider
Star Strider 2017 年 6 月 18 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by