how to import repeating block data of text file in MATLAB?
조회 수: 5 (최근 30일)
이전 댓글 표시
Hi,
i have a few datasets need to be processed, but i dont know how to import them to the matlab since I am a biginner of MATLAB. The data looks like this:
0126
NANO0840 2011-07-15 12:11:29 12.1v INL 39.0% 40.0 DegC
OPER L.Z TX ID 1 A-SP 100 M
JOB 001 LINE 1 N SPREAD 1
50% RxM 250 TxX 20 TxY 20 #T 1
Tx Delay 1.5 Antenna Delay 2 Alias IN
Robust None Window ZONGE
1 NanoTEM A/D 16-bit S/N 64 Passed 1.00000
Front Panel S/N 56, Cal S/N 172, Temp 40.0, Humidity 39.0, EPROM BD387 0840
0127
NANO0840 2011-07-15 12:13:14 12.1v INL 39.0% 40.0 DegC
Tx 1 Rx 1 N OUT
64 Hz 128 Cyc Tx Curr 3 4.819u 1u 1.606u
1 Hz 1 222.94u 80.23u 24.82 000O 62.23u 0.00 0
Wn Mag 1 Rho 1
0.319u 1.5825 674.98
1.925u 0.4227 81.201
3.531u 0.1736 53.453
5.137u 90.065m 44.321
6.743u 53.728m 39.743
8.350u 34.973m 37.061
10.73u 21.064m 34.221
13.95u 11.979m 32.190
17.16u 7.5831m 30.896
21.14u 4.8296m 29.500
25.97u 3.1097m 28.075
32.28u 1.9126m 27.009
41.08u 1.1106m 25.968
51.49u 659.11u 25.235
64.24u 376.08u 25.367
80.23u 222.94u 24.824
100.9u 110.88u 26.994
128.0u 66.548u 25.512
161.6u 30.614u 29.035
203.1u 12.955u 35.197
255.0u 11.043u 26.791
321.0u 10.813u 18.504
404.9u 13.808u 10.678
508.7u -0.9989u 42.045
639.4u 4.7662u 10.133
805.4u 5.4792u 6.2862
1.014m 2.5061u 7.2169
1.276m 2.7276u 4.6476
1.607m 0.0791u 33.511
2.022m 1.8926u 2.7528
2.547m 2.7681u 1.4547
except of block 126, the other blocks are the same.each block i am able to use the textscan to import one block of data, but have no idea how to import all of these data in one time. Anybody would like to give a hand?
Thanks a lot.
댓글 수: 2
채택된 답변
Walter Roberson
2011년 7월 26일
fid = fopen('filename');
textscan(fid, '', 1, 'headerlines', 10); %skip entire block
C = {};
while true
thisblock = textscan('%f%*c%f%*c%f', 31, 'headerlines', 6, 'CollectOutput', 1);
if all(cellfun(@isempty,thisblock)); end; break; %end of file
C{end+1} = thisblock{1};
end
Warning: this ignores the 'u' and 'm' suffixes. You have not given any indication of how you want to handle those.
This code will produce one cell array in C per block read in.
This code makes no attempt to read anything out of the first block.
This code makes no attempt to read the block number or any other header.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!