Find general non-constant solution for differential equation

5 ビュー (過去 30 日間)
Borjan Trajanoski
Borjan Trajanoski 2020 年 5 月 7 日
コメント済み: Ameer Hamza 2020 年 5 月 8 日
eqn=diff(y(t),t) == k*y*(1-y/M);
S=dsolve(eqn);
Sz = S(3) %general non-constant solution
>> Sz = M/(exp(-M*(C1 + (k*t)/M)) + 1)
If I put my code in matlab, for Sz I get an 3x1 array with
S(1) = 0
S(2) = M
S(3) = M/(exp(-M*(C1 + (k*t)/M)) + 1)
Now I know the solution to this problem is in S(3) as seen in the code, but is there a way how Matlab can find the solution without me looking into the array of Sz?
Thanks!

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 7 日
All three solution given by dsolve() satisfies the differential equation. So, I guess you want to get the solution which depends on time. You can do it like this
syms y(t) M k
eqn=diff(y(t),t) == k*y*(1-y/M);
S=dsolve(eqn);
idx = arrayfun(@(x) ismember(t, symvar(x)), S);
S = S(idx);
  2 件のコメント
Borjan Trajanoski
Borjan Trajanoski 2020 年 5 月 8 日
Thank you, that helped me very much!
Ameer Hamza
Ameer Hamza 2020 年 5 月 8 日
I am glad to be of help.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by