Converting cell array containing char to array.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mohamed Abdelsamie
am 21 Feb. 2019
Beantwortet: Stephen23
am 21 Feb. 2019
Hi,
I have a few cell arrays that contain char arrays that I need to convert to a single array. Currently the contents of the cell arrays are either numbers or [] for empty cells.
I tried cell2mat, str2num, str2double and all didn't work.
I attached one of the cell arrays.
Any help would be greatly appreciated.
Thanks
2 Kommentare
Fangjun Jiang
am 21 Feb. 2019
How do you want to convert "chars" to single array? You can make up a simple cell array to show your problem.
Akzeptierte Antwort
Weitere Antworten (1)
Mohamed Abdelsamie
am 21 Feb. 2019
Bearbeitet: Mohamed Abdelsamie
am 21 Feb. 2019
4 Kommentare
Stephen23
am 21 Feb. 2019
Bearbeitet: Stephen23
am 21 Feb. 2019
"Vertcat didn't change the cell array at all"
I would not expect vertcat to "change" anything. All it does is vertically concatenate its inputs together. Which is exactly what you showed in your answer... vertcat with a comma-separated list is just simpler than what you wrote:
desired_array = vertcat(cell_array{1,1:8})
Siehe auch
Kategorien
Mehr zu Logical 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!