Converting cell array containing char to array.
조회 수: 4 (최근 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에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!