Transforming 100x4 Char Array to 1x400 Char Array
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a char array with the dimensions of 100x4 and because it contains blank elements, in other words 4 charactered space ' ', I want to merge these elements and delete these 4 charactered blank elements. How can I do it? Thank you.
2 个评论
Rik
2022-6-7
If you want to remove elements, this will change the number of elements, so any column vector will not have 400 elements.
It sounds like you should be using a cellstr (a cell array with char vectors) or the string data type.
采纳的回答
KSSV
2022-6-7
You have varities of functions to achieve this.
Try:
str = str(find(~isspace(str))) ; % where str is your string
5 个评论
Rik
2022-6-7
I don't understand your source data. With a 2x6 char array as an input, you don't get the cell array output with the code KSSV posted. So I can't post the full processing.
Regarding the merging:
str={'0E';'F9'}
[str{:}]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!