Combine two cell arrays into a block diagonal array
조회 수: 3 (최근 30일)
이전 댓글 표시
The function blkdiag can be used to combine two numerical arrays with different dimensions into a block diagonal matrix, with 0s in the missing locations. Is there anything similar for two cell arrays, where the missing elements would just be empty cells? (I could do it manually, just wondering if there is a built-in function to keep my code clean as with blkdiag). Thanks!
댓글 수: 0
답변 (1개)
Walter Roberson
2018년 2월 10일
n = numel(YourCell);
out = cell(n, n);
out(1:n+1:end) = YourCell;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!