Extracting the base name and size of symbolic variables
4 views (last 30 days)
Show older comments
Hello,
I have a simple question. Consider the following:
syms a [3 3] real
syms x r [3 1] real
mu(x) = (r.*x).*(1-a*x)
Now, I would like to know the symbolic variables and their sizes in the symbolic function mu(x). If I use symvar(mu) I can only get the
variables in a scalar form and this command does not help to get the size of matrixes and vectors. You might think that it should not be
a big deal to write a code for this. However, ingeneral this is not possible. Foe instance, consider the following example:
syms x beta0 w w0 w1 w2
mu(x) = x+beta0+w+w0+w1+w2
In this example there is not a unique interpretation of the variables in terms of matrices, vectors, and scalars. One interpretation is to consider w = [w1 w2] as a vector. But, another interpretation is to consider al w's as scalar (which is the correct interpretation).
Why I need this?
I am performing a parameter estimation procedure to estimate the parameters of a function like mu(x). When I want to represent the results I do not like to display them scalar-wiae. rather I prefer to display the outcomes based on their actual sizes.
I hope MATLAB has a command to handled this issue?
Thanks,
Babank
0 Comments
Answers (1)
Walter Roberson
on 20 Sep 2024
syms a [3 3] real
That is equivalent to
a = sym('a', [3 3], 'real')
mu(x) = (r.*x).*(1-a*x)
When scanning that code, the value of a is substituted, as-if you had written
mu(x) = (r.*x).*(1-sym('a', [3 3], 'real')*x)
The code does not remember that the value came from the variable a
So what you want to do is not possible.
4 Comments
Walter Roberson
on 20 Sep 2024
The substitution of the value for the variable is inherent in how symbolic mathematics works. There is no chance that you would be able to recover variable a from mu(x) = (r.*x).*(1-a*x);
See Also
Categories
Find more on Special Values in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!