MATLAB: Help splitting string using strsplit

MATLABstrsplit

I have a large set of data which is presented as a string, for example:
1;2;3;4;5;6;7;8 etc…
I use:
strsplit(data,';')
and that breaks everything up into individual cells.
However I have found an issue with some data. My logger is 100% reliable so sometimes I get data which looks like:
;;;;;6;7;8 etc…
Using the strsplit command I get:
NaN 6 7 8
What I'd like is
NaN NaN NaN NaN NaN 6 7 8
Any suggestions?

Best Answer

Richard - from strsplit try doing the following
strsplit(data, ';', 'CollapseDelimiters', false)
so that the consecutive empty delimiters are not collapsed into one cell.