csv - How do I read in MATLAB a text file of doubles with variable number of columns per line? -


my file looks this:

1 2 3 4 5 6 7 8 9 ... 

i'm looking matlab one-liner (or two) can turn into:

c{1} = [1 2 3 4] c{2} = [5 6] c{3} = [7 8 9] 

here one-liner, broken several lines readability

c = cellfun(@(x) sscanf(x, '%f').', ...         regexp(...             regexprep(...                 fileread('test.txt'), ...                 '(\r|\n$)', ''), ...             '\n', 'split'), ...         'uni', 0).'; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -