How to expand the matrix into two matrix

3 次查看(过去 30 天)
How to expand matrix into different matrix?
For example A=[ b*x1 c*x2];
into [b c]*[x1;x2]
  2 个评论
Stephen23
Stephen23 2020-4-18
Unless you give more information there are infinite b, c, x1, and x2 values that satisfy your question. Be more precise.

请先登录,再进行评论。

回答(1 个)

John D'Errico
John D'Errico 2020-4-18
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]

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by