white space in cell array
3 次查看(过去 30 天)
显示 更早的评论
am using textscan to read text file and I get <55x1 cell> examples:
'aa a aa'
'a aaaa a'
'a = aaaaa'
'aaaaaa'
' a a a aaa'
'aa'
'aaa'
'aaaa'
.
.
.
.
I want to delete the white spaces in each sting. for example, If I have a sting
string = 'I am 24 Years old'
And I use
string(ismember(string,' ')) = [];
it will eliminate the spaces and I will get
'Iam24Yearsold'
But with the cell doesn't work or I don't know how to do it How can I do that? any suggestions please?
0 个评论
采纳的回答
Andrei Bobrov
2013-7-23
编辑:Andrei Bobrov
2013-7-23
string = 'I am 24 Years old';
strrep(string,' ','');
for cell array
string = {'I am 24 Years old';'I am 24 Years old'}
strrep(string,' ','');
3 个评论
更多回答(1 个)
Azzi Abdelmalek
2013-7-23
s={'aa a aa'; 'a aaaa a'; 'a = aaaaa'}
out=cellfun(@(x) x(~ismember(x,' ')),s,'un',0)
1 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cell Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!