find out dependent variables from an expression

3 views (last 30 days)
syms x(t)
y=x^2+2;
symvar(y)
It gives the ans as t.
Desired output is x. How to get the desired output.
Thanks in advance

Accepted Answer

Walter Roberson
Walter Roberson on 6 Apr 2022
syms x(t)
y=x^2+2;
findSymType(y, 'symfun')
ans = 

More Answers (1)

Cris LaPierre
Cris LaPierre on 5 Apr 2022
syms x
y=x^2+2;
symvar(y)
ans = 
x
  2 Comments
Cris LaPierre
Cris LaPierre on 5 Apr 2022
Then the symvar is t, as you see. symvar returns symbolic variables in an expression. As you have set it up, x and y are symbolic functions, not variables. t is the only symbolic variable.

Sign in to comment.

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!