How to create a matrix with matrices as elements? where the matrix A contains symbolic variables

4 ビュー (過去 30 日間)
  3 件のコメント
dpb
dpb 2022 年 5 月 14 日
編集済み: dpb 2022 年 5 月 15 日
Pretty much just write the terms in an array - the products are all 1x1 so the summations are as well.
You'll have to define what P is and have a routine that computes the number of terms to fill in the right number of zeros -- and it's certainly not unambiguous what might be the intermediary ... terms going from third row to last. It may be possible to infer from the context from which this was extracted, but not on its own.

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

採用された回答

Voss
Voss 2022 年 5 月 14 日
It may be useful to see the fact that, for matrices A, B, and C of the given sizes, the products C*B, C*A*B, C*A^2*B, etc., are all scalars, so any sum of those products is a scalar. Therefore, all those expressions are actually scalars, so it's not in fact a matrix of matrices like it seems to be at first glance.
Each of those scalars can be calculated in a for loop to perform the summation:
A = [1 2; 3 4];
B = [1; 2];
C = [1 2];
p = 7;
m = 5;
M = zeros(p,m);
for kk = 1:p % loop over rows
for jj = 1:m % loop over columns
for ii = 0:kk-jj % summation loop for element kk,jj
% note that kk<jj gives "for i = []", so this loop doesn't
% execute when kk<jj, and M(kk,jj) remains at 0.
% kk<jj corresponds to the upper triangular part of M,
% which should be all zeros, so that works out nicely.
M(kk,jj) = M(kk,jj) + C*A^ii*B;
end
end
end
M
M = 7×5
5 0 0 0 0 32 5 0 0 0 177 32 5 0 0 956 177 32 5 0 5141 956 177 32 5 27624 5141 956 177 32 148409 27624 5141 956 177
  3 件のコメント
Sarala Gurijala
Sarala Gurijala 2022 年 5 月 15 日
But, In my problem Matrix A has the symabolic variables, then what changes should I do. suggest me
Thanks in advance for once again
Voss
Voss 2022 年 5 月 19 日
Maybe the first comment on the question provides some insight.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeOperators and Elementary Operations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by