How to expand the matrix into two matrix

3 Ansichten (letzte 30 Tage)
Mohit Bhatia
Mohit Bhatia am 18 Apr. 2020
Kommentiert: Mohit Bhatia am 18 Apr. 2020
How to expand matrix into different matrix?
For example A=[ b*x1 c*x2];
into [b c]*[x1;x2]
  2 Kommentare
Stephen23
Stephen23 am 18 Apr. 2020
Unless you give more information there are infinite b, c, x1, and x2 values that satisfy your question. Be more precise.
Mohit Bhatia
Mohit Bhatia am 18 Apr. 2020
b,c x1,x2 are variables

Melden Sie sich an, um zu kommentieren.

Antworten (1)

John D'Errico
John D'Errico am 18 Apr. 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]

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by