フィルターのクリア

Hi i have made a separable differential equation now i want to put values of t at instant, equations are made but i down know how to put value

1 回表示 (過去 30 日間)
syms A(t) C(t) k
k=4;
ode1=diff(A,t)==-k*A
ode2=diff(C,t)==k*A
odes=[ode1;ode2]
S=dsolve(odes)
Asol(t)=S.A
Csol(t)=S.C
[Asol(t), Csol(t)]=dsolve(odes)
cond1=A(0)==5
cond2=C(0)==5
conds=[cond1;cond2]
[Asol(t),Csol(t)]=dsolve(odes,conds)

回答 (2 件)

Star Strider
Star Strider 2018 年 2 月 1 日
When you run your code, you create ‘Asol’ and ‘Csol’ as functions. So you only need to give them numeric arguments (here 3 arbitrarily) to get the result:
Result_1 = vpa(Asol(3))
Result_2 = vpa(Csol(3))
Result_1 =
0.000030721061766641048793411540894028
Result_2 =
9.9999692789382333589512065884591
  7 件のコメント
Star Strider
Star Strider 2018 年 2 月 1 日
My code takes advantage of the original code creating functions, so you only need to deal with them as straightforward functions. It is much simpler and more efficient.
Walter Roberson
Walter Roberson 2018 年 2 月 1 日
vpa() and subs() and calling the symbolic function with numeric values will all produce symbolic results. Those symbolic results can increasingly be used in place of numeric results, but not in all contexts.
To get a numeric result, apply double() to the symbolic result. Like double(Asol(1.234))

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


Walter Roberson
Walter Roberson 2018 年 2 月 1 日
For example:
t_values = linspace(0, 10, 100);
plot(t_values, Asol(t_values))

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by