Splitting a matrix into addition of two same size Matrices

1 回表示 (過去 30 日間)
Sidharth Agarwal
Sidharth Agarwal 2020 年 7 月 28 日
回答済み: Walter Roberson 2020 年 7 月 30 日
A 12*12 Matrix P is given to us,this matrix has each of it's element as a quadratic expression in symolic variable x3.This Matrix P needs to be made into an addition of 3 different 12*12 matrices A,B,C such that P=A*x3^2+B*x3+C
How can we find these matrices A,B,C in matlab ?

回答 (2 件)

KSSV
KSSV 2020 年 7 月 28 日
編集済み: KSSV 2020 年 7 月 28 日
x3 = rand(12) ;
A = rand ;
B = rand ;
C = rand ;
P = A*x3.^2+B*x3+C ;
If A, B, C are matrices
x3 = rand(12) ;
A = rand(12) ;
B = rand(12) ;
C = rand(12) ;
P = A.*x3.^2+B.*x3+C ;
  3 件のコメント
KSSV
KSSV 2020 年 7 月 29 日
Okay..you mean you have P, A, B, C matrices..and you want x3.?
Sidharth Agarwal
Sidharth Agarwal 2020 年 7 月 30 日
It is mentioned in the orginal question that I have a 12*12 P matrix which has each of it's element as a quadratic expression in symbolic variable x3.This Matrix P needs to be made into an addition of 3 different 12*12 matrices A,B,C such that P=A*x3^2+B*x3+C
How can we find these matrices A,B,C in matlab ?

サインインしてコメントする。


Walter Roberson
Walter Roberson 2020 年 7 月 30 日
parts_cell = arrayfun(@(s) coeffs(s,x3,'all'), P, 'uniform', 0);
parts_matrices = num2cell(vertcat(parts_cell{:}),1);
A = reshape(parts_matrices{1}, size(P));
B = reshape(parts_matrices{2}, size(P));
C = reshape(parts_matrices{3}, size(P));

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by