Reading and grouping data from file

Hi I have to read a data from the file. Readings from several hours, are saved in in this format:
TIME 00:00
A B C
0.25 90.000 774
0.48 116.554 2851
0.50 148.259 3094
0.60 175.225 4455
1.30 201.503 20916
1.40 205.942 24257
1.70 217.980 35767
1.80 221.841 40099
2.80 265.374 97030
2.95 278.601 107704
TIME 05:30
A B C
0.25 40.000 774
0.30 72.111 1114
0.70 145.267 6064
2.00 275.841 49505
3.10 292.110 118936
3.17 293.396 124368
TIME 12:00
A B C
0.25 40.000 774
0.30 92.111 1114
0.40 97.351 1980
0.50 110.000 3094
0.48 125.014 2851
0.50 137.337 3094
0.60 153.750 4455
I would like to read every part of data for every hour separately, and in the future group for every hour parameters A,B and C. I was trying in few ways but with no good effects
Thank You very much for Your time.

댓글 수: 3

Image Analyst
Image Analyst 2013년 1월 30일
Do you have an example of what that output would be?
Output can be quite unrestricted, as easier to propose a solution.
But as I think It will be good as cells.
The final output for me, that I can use in other calcutions is with the easiest access to parameters A B C in every TIME.
So maybe example of output for Time 05:30:
0530 =
{0.25} { 40.000} { 774}
{0.30} { 72.111} { 1114}
{0.70} {145.267} { 6064}
{2.00} {275.841} { 49505}
{3.10} {292.110} {118936}
{3.17} {293.396} {124368}
per isakson
per isakson 2013년 1월 30일
편집: per isakson 2013년 1월 30일
There are two reasons to put each block of numerical values in a double array and each array in a cell of a cell array
  • saves on memory (a lot)
  • makes faster code possible
result( block_number ) = ...
{[0.25 40.000 774
0.30 92.111 1114
0.40 97.351 1980
0.50 110.000 3094
0.48 125.014 2851
0.50 137.337 3094
0.60 153.750 4455]}

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

 채택된 답변

per isakson
per isakson 2013년 1월 30일
편집: per isakson 2013년 1월 31일

0 개 추천

Hint:
  • read the file and find the row numbers of "TIME": ixt
  • read the file a second time one block at a time controlled by ixt
  • the second time the file is in the file cache and reading is fast
function M = Answer( )
fid = fopen( 'cssm.txt', 'r' );
cac = textscan( fid, '%s', 'Delimiter', '\n' );
sts = fclose( fid );
ixt = find( strncmp( 'TIME', cac{1}, 4 ) );
end

댓글 수: 1

ZK
ZK 2013년 1월 31일
편집: ZK 2013년 1월 31일
Thank You very much for Your help. I used Your hints + I wrote one loop with deleting first digit from ixt, and reading next data. Best regards. ZK

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Text Data Preparation에 대해 자세히 알아보기

질문:

ZK
2013년 1월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by