How to say that a constant is not a variable?

3 views (last 30 days)
Hi,
I would like to solve an ode in a analytic way
So i do:
df= @(,) ...
syms T(t)
df1=sym(df);
y0=10 % a constant
f_exact = matlabFunction(dsolve(diff(T,1) == df1 , T(0)== y0));
If I run that i am getting f_exact=@(t,y0) ... % function of t and y0
How wan i do to say that y0 is a constant
Thank you
  2 Comments
Walter Roberson
Walter Roberson on 1 Jun 2018
Could you give us df itself to test with?
Quentin Dragomir
Quentin Dragomir on 1 Jun 2018
df = @(t,T) -0.1*(T -10);
df1= 1 - T/10
If I do
f_e = matlabFunction(dsolve(diff(T,1) == -0.1*(T-10),T(0) == 100)) It works, but i need a dynamic code so I can't write it

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 1 Jun 2018
When you do
df = @(t,T) -0.1*(T -10);
then the T is taken from the second argument of df, not from the syms T(t). When you sym(df) then the T that appears in the result is a different T, not the same one as syms T(t) .
Instead of using
df1 = sym(df)
you should be using
syms T(t)
df1 = df(t,T)

More Answers (0)

Community Treasure Hunt

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

Start Hunting!