Effacer les filtres
Effacer les filtres

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 vue (au cours des 30 derniers jours)
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)

Réponses (2)

Star Strider
Star Strider le 1 Fév 2018
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 commentaires
Star Strider
Star Strider le 1 Fév 2018
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 le 1 Fév 2018
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))

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 1 Fév 2018
For example:
t_values = linspace(0, 10, 100);
plot(t_values, Asol(t_values))

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by