Converting cell array containing char to array.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Fangjun Jiang
2019-2-21
How do you want to convert "chars" to single array? You can make up a simple cell array to show your problem.
采纳的回答
更多回答(1 个)
Mohamed Abdelsamie
2019-2-21
编辑:Mohamed Abdelsamie
2019-2-21
4 个评论
Stephen23
2019-2-21
编辑:Stephen23
2019-2-21
"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})
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!