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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -