read .txt to cell array with keeping the row and column structure

조회 수: 1 (최근 30일)
I want to read in .txt that looks like this:
23.06.2011 09:53:48.2153 CAN #2 | Rx 0e4 8 26 73 74 22
23.06.2011 09:53:48.2182 CAN #2 | Rx 281 2 7b f3
23.06.2011 09:53:48.2204 CAN #2 | Rx 1b3 00 ff 80 26
23.06.2011 09:53:48.2225 CAN #2 | Rx 199 1d 80 ff 2f
but then with quite a few more lines in the same format, and save it as a cell array that keeps the row and column structure. Just doing textscan will make a X by 1 array where the rows and columns are lost. Any know what to do? thanx!

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 8월 29일
fid=fopen('test.txt','rt');
a=textscan(fid,repmat('%s ',1,12))
fclose(fid);
  댓글 수: 1
Joris
Joris 2011년 8월 29일
i did it without the repmat part (used a loop to make rows), but this is probably faster and would have save me much work

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by