フィルターのクリア

Create parametric block diagonal matrix

2 ビュー (過去 30 日間)
Mehdi Ghasem Moghadam
Mehdi Ghasem Moghadam 2017 年 2 月 15 日
コメント済み: Star Strider 2017 年 2 月 15 日
how can create parametric block diagonal matrix in Matlab
for i=1:2
H = blkdiag(sym('H%d',num2str(i),[1 1]));
end

回答 (1 件)

Star Strider
Star Strider 2017 年 2 月 15 日
See if this does what you want:
h = sym('H%d',[1 2]); % Create Vector
h = mat2cell(h, 1, [1 1]); % Convert Vector To Cell Array Of Individual Elements (Comma-Separated List)
H = blkdiag(h{:}) % Desired Result
H =
[ H1, 0]
[ 0, H2]
The blkdiag function wants a comma-separated list, and a cell array provides that. This code creates your initial vector (as I believe you want it), then converts it to a cell array, then uses it to create your block-diagonal matrix.
If this is not the result you want, please describe in detail what you want your desired result to be.
  2 件のコメント
Mehdi Ghasem Moghadam
Mehdi Ghasem Moghadam 2017 年 2 月 15 日
Thanks, but I need Block Diagonal matrix like: H = [ H1, 0] [ 0, H2] [ 0, H3]
Star Strider
Star Strider 2017 年 2 月 15 日
This seems to do what you want:
h = sym('H%d',[1 3]); % Create Vector
h = mat2cell(h, 1, [1 2]); % Convert To Cell Array
H = blkdiag(h{:}).' % Desired Result (Simple — Not Complex Conjugate — Transpose)
H =
[ H1, 0]
[ 0, H2]
[ 0, H3]

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

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by