matlab - white space in cell array -


i using textscan read text file , <55x1 cell> examples:

 'aa aa'  'a  aaaa a'  'a =  aaaaa'  'aaaaaa'  ' a aaa'  'aa'  'aaa'  'aaaa'   .   .    .   . 

i want delete white spaces in each sting if have sting

 string = 'i 24 years    old' 

and use

  string(ismember(string,' ')) = []; 

it eliminate spaces ,

 'iam24yearsold' 

but cell doesn't work or don't know how how can that? suggestions please?

you can use strrep:

a = { 'aa aa'  'a  aaaa a'  'a =  aaaaa'  'aaaaaa'  ' a aaa'  'aa'  'aaa'  'aaaa'  'i 24 years    old'};  strrep(a, ' ', '') 

this results in

ans =       'aaaaa'     'aaaaaa'     'a=aaaaa'     'aaaaaa'     'aaaaaa'     'aa'     'aaa'     'aaaa'     'iam24yearsold' 

Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -