Read a whole text file into a MATLAB variable at once

后端 未结 5 696
忘了有多久
忘了有多久 2021-02-10 23:46

I would like to read a (fairly big) log file into a MATLAB string cell in one step. I have used the usual:

s={};
fid = fopen(\'test.txt\');
tline = fgetl(fid);
w         


        
5条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-11 00:21

    s = regexp(fileread('test.txt'), '(\r\n|\n|\r)', 'split');

    The seashells example in Matlab's regexp documentation is directly on-point.

提交回复
热议问题