Block Diagonal

버전 1.0.0 (1.68 KB) 작성자: Lateef Adewale Kareem
This code allows you to process block diagonal elements. Its like the generalization of inbuilt diag.
다운로드 수: 7
업데이트 날짜: 2022/5/27

라이선스 보기

% if size(v,2) == n
% D = diag(v) returns a square diagonal matrix with the block
% (m-by-n) elements of matrix v when on the main diagonal.
% D = diag(v, k) places the (m-by-n) elements of vector v on the kth
% block diagonal. k = 0 represents the main diagonal, k > 0 is above
% the main diagonal, and k<0 is below the main diagonal.
% end
% if size(v,2) > n
% D = diag(v) returns a matrix size(v, 1)-by-n made of block
% (m-by-n) main diagonal elements of matrix v.
% D = diag(v, k) extracts (m-by-n) block elements from matrix v on the
% kth block diagonal. k = 0 represents the main diagonal, k > 0 is above
% the main diagonal, and k<0 is below the main diagonal.
% end
% Note that if v has just 1 column, m = 1, and n = 1, then BlockDiag
% behaves exactly like the inbuilt function Diag.
A = rand(12);
v1 = BlockDiag(A, 2, 2)
v2 = BlockDiag(A, 2, 2, 1)
v3 = BlockDiag(A, 3, 2, -1)
v = rand(12,3);
D1 = BlockDiag(v, 3, 3)
D2 = BlockDiag(v, 3, 3, -1)
D3 = BlockDiag(v, 4, 3, 1)

인용 양식

Lateef Adewale Kareem (2024). Block Diagonal (https://www.mathworks.com/matlabcentral/fileexchange/112325-block-diagonal), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2022a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0