How can I read the entire contents of a file into a cell array with one line per cell?
조회 수: 15 (최근 30일)
이전 댓글 표시
I would like to read the entire contents of a file. In the end, I'd like to have a cell array, where each cell contains a line from the file.
채택된 답변
MathWorks Support Team
2009년 6월 27일
There is no single function that does this in MATLAB, although several functions can be combined to do this.
For instance,
str = fileread('foo.txt');
lines = regexp(str, '\r\n|\r|\n', 'split');
reads "foo.txt" into a string, and then splits the string into cells according to newline combinations.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!