.txt to matrix separated by blank lines
조회 수: 1 (최근 30일)
이전 댓글 표시
I have txt files of 2 columns, where different trials are separated by two blank lines. How can I convert this data into matrices, where each trial is in a different matrix? Thank you for any help.
댓글 수: 0
답변 (1개)
Nikhil Sapre
2021년 6월 25일
Hi Alyse,
Can you try something similar to this?
FileList = dir('*.txt');
[~,idx] = sort([FileList.datenum]);
FileData = [];
for iFile = 1:numel(idx)
currFile = FileList(idx(iFile)).name;
FileData.(['file_' num2str(iFile)]) = load(currFile);
end
Make sure your current directory is your .txt files are located.
Thanks,
Nikhil
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!