MATLAB Answers

0

How to split string with commas to columns?

Asked by Kelly Kyriakou on 28 Nov 2015
Latest activity Commented on by Star Strider
on 28 Nov 2015
How to split thsi string to columns with delimiter the comma? '10009_10383,195,1.73936,0.54069,0.579311,56,0,0,0,0,0,0,0,0,0,0,0,0,'
I tried strsplit but I receive the following error 'First input must be a string.'

  0 Comments

Sign in to comment.

1 Answer

Answer by Star Strider
on 28 Nov 2015
 Accepted Answer

One possibility:
in = '10009_10383,195,1.73936,0.54069,0.579311,56,0,0,0,0,0,0,0,0,0,0,0,0,';
out = regexp(in, ',', 'split');
out = out(1:end-1)
out =
'10009_10383' '195' '1.73936' '0.54069' '0.579311' '56' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0'
Note that ‘out’ is a (1x18) cell.

  2 Comments

Thank you very much!
As always, my pleasure!

Sign in to comment.