Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的文件如下所示:
1 2 3 4 5 6 7 8 9 ...
我正在寻找一个 MATLAB 单行(或两个)可以把它变成:
C{1} = [1 2 3 4] C{2} = [5 6] C{3} = [7 8 9]
这是一个单行,为了便于阅读,分成几行
C = cellfun(@(x) sscanf(x, '%f').', ... regexp(... regexprep(... fileread('test.txt'), ... '(\r|\n$)', ''), ... '\n', 'split'), ... 'uni', 0).';