필터 지우기
필터 지우기

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 CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by