Search code examples
matlabcell-array

Remove any spaces between ' ' in cell array Matlab


I have this cell array

aitransp = 

Columns 1 through 14

'27'    '26'    '25'    '24'    '23'    '22'    '21'    '20'    '19'    '18'    '17'    '16'    '15'    '14'

Columns 15 through 21

'13'    '12'    '11'    ' 9'    ' 8'    ' 7'    ' 1'

As you can see, the last 4 elements have a space between the ' ', such as ' 9'. Is there any way to remove any spaces occurring between '' in a cell array?

Thanks in advance..


Solution

  • Just use strtrim, you don't have to convert to string

    strtrim(aitransp)