Concatenate cell array inside a cell array
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti

My cell array is of different size. I want to convert it to the matrix. I added NAN to make the size equal but I found NAN added inside a cell array like the picture [1*481]. I try to horzcat it but did not work. Can anyone help me, please?

0 Commenti
Risposte (1)
Voss
il 24 Set 2023
C = {rand(1,7),rand(1,4),rand(1,3)};
disp(C);
num = cellfun(@numel,C);
N = numel(C);
M = NaN(N,max(num));
for ii = 1:N
M(ii,1:num(ii)) = C{ii};
end
disp(M);
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!