Combine two cell arrays into a block diagonal array

2 Ansichten (letzte 30 Tage)
Myrtle42
Myrtle42 am 10 Feb. 2018
Beantwortet: Walter Roberson am 10 Feb. 2018
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!

Antworten (1)

Walter Roberson
Walter Roberson am 10 Feb. 2018
n = numel(YourCell);
out = cell(n, n);
out(1:n+1:end) = YourCell;

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by