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 で Operating on Diagonal Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!