简体   繁体   中英

How to find the linear parameterization of a symbolic vector in MATLAB

I have a symbolic vector y which I know contains linear expressions of the variables contained in a symbolic vector theta. Is there a way to compute the symbolic expression of A, where y = A * theta? I tried y*pinv(theta) but it doesn't seem to work.

Example:

syms a b real
theta = [a;b];
y = [2*a;2*b];

y*pinv(theta) gives

ans =   [ (2*a^2)/(a^2 + b^2), (2*a*b)/(a^2 + b^2)] 
        [ (2*a*b)/(a^2 + b^2), (2*b^2)/(a^2 + b^2)]

and

y/theta gives

ans =   [       2, 0]
        [ (2*b)/a, 0]

along with a warning that the solution is not unique. I want to eradicate the symbolic variables from my result ie I want

ans =   [ 2, 0]
        [ 0, 2]

The equationsToMatrix function seems to be doing the job! Try equationsToMatrix(y,theta)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM