How to expand the matrix into two matrix
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
How to expand matrix into different matrix?
For example A=[ b*x1 c*x2];
into [b c]*[x1;x2]
2 commentaires
Stephen23
le 18 Avr 2020
Unless you give more information there are infinite b, c, x1, and x2 values that satisfy your question. Be more precise.
Réponses (1)
John D'Errico
le 18 Avr 2020
Assuming you want to essentially factor a symbolic expression into what is essentially a dot product between two vectors, I would first point out the solution is not unique. ;-)
b*x1 + c*x2 = dot([ 1 1],[b*x1,c*x2])
One problem is you don't seem to appreciate that what you wrote would result in a SCALAR variable, whereas A is a 1x2 VECTOR. That is, this expression is a DOT PRODUCT between a row and a column vector.
[b c]*[x1;x2]
which will result in a 1x1 scalar variable, not a vector. So it is absolutely impossibly to do what you ask.
You could use an element-wise multiplication, so using the .* operator, which here would apply between a pair of ROW vectors to produce the vector A.
Or, you could use a dot product, which will produce a scalar variable which is the sum of those terms.
Perhaps what you really want to use is the coeffs function:
help coeffs
--- help for sym/coeffs ---
coeffs Coefficients of a multivariate polynomial.
C = coeffs(P) returns the coefficients of the polynomial P with respect to
all the indeterminates of P.
But so far, I don't even know what it is exactly that you are asking to do. This might be the kind of thing you want to do however:
syms x y
z = 3*x^2*y^2 + 5*x*y^3;
coeffs(z) = [5, 3]
coeffs(z,x) = [5*y^3, 3*y^2]
[c,t] = coeffs(z,y) returns c = [5*x, 3*x^2], t = [y^3, y^2]
0 commentaires
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!