Merging Cell Array Elements with cellstr
이전 댓글 표시
Hello,
I want to merge the elements of the cell array of 100x4. After this merge, it will become 100x1. To do this process, I am using
temp = string(reshape(cell_temp, [], 4));
merged= cellstr(temp(:,1) + temp(:,2) + temp(:,3) + temp(:,4))
Are there any other methods to merge them in shorter way? Because sometimes I want to merge 15 elements but I don't want to write them explicitly. Thank you.
채택된 답변
추가 답변 (1개)
Simon Chan
2022년 6월 9일
Try this:
merged = cellfun(@(x) cat(2,x{:}),num2cell(cell_temp,2),'UniformOutput',false)
카테고리
도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!