Convert Cell to array did not work ?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
shawin
am 28 Dez. 2020
Beantwortet: Walter Roberson
am 28 Dez. 2020
Hi,
I have a cell array wich is
1x561 double
1x321 double
1x481 double
when i try to convert it to array using the code on mathwork which is :
maxEl=561;%max number of elements of a cell element in your cell
C=cell2mat(cellfun(@(x) [cell2mat(x) zeros(1,maxEl-numel(x))],hx,'uni',0))
did not work , and also the code :
c2 = cellfun(@(x) [x{:}], c, 'un',0) % convert to cell array of numeric array
[m, tf] = padcat(c2{:}) % concatenate, pad rows with NaNs
m(~tf) = 0 % replace NaNs by zeros
Any suggestion please !!!
Thanks
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 28 Dez. 2020
C = cell2mat(cellfun(@(x) [x zeros(1,maxEl-numel(x))], hx(:), 'uni', 0));
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!