필터 지우기
필터 지우기

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 CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by