delete zeros in cell array
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Elysi Cochin
am 13 Apr. 2021
Kommentiert: Elysi Cochin
am 14 Apr. 2021
i have a cell_array with values
cellarr = {'b','a','a','a','b';0,'c',0,'b',[];0,'a',0,'d',0;'a','a','b',[],[]};
i wanted to delete the zeros in the cell_array so as to get the new cell array as below
shift the remaining columns to left after deleting the zero
new_cellarr = {'b','a','a','a','b';'c','b',[],[],[];'a','d',[],[],[];'a','a','b',[],[]};
1 Kommentar
madhan ravi
am 13 Apr. 2021
I think what you are describing is not what show in the expected result.
Akzeptierte Antwort
Matt J
am 13 Apr. 2021
Using the attached file sortlidx.m,
cellarr = {'b','a','a','a','b';0,'c',0,'b',[];0,'a',0,'d',0;'a','a','b',[],[]}
map=cellfun(@isnumeric,cellarr);
cellarr(map)={[]};
[~,isort]=sortlidx( ~map ,2,'descend');
cellarr = cellarr(isort)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Type Conversion 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!