Extracting the base name and size of symbolic variables
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Walter Roberson
2024년 9월 20일
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
Walter Roberson
2024년 9월 20일
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);
참고 항목
카테고리
Help Center 및 File Exchange에서 Special Values에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!