how to accumulation a cell (x) data. from 30 file data.

조회 수: 2 (최근 30일)
Soni huu
Soni huu 2012년 7월 3일
i have 1440x9 cell data from a file, n i have 360 file data in a folder. how to accumulation data cell 3, from 30 file data.
ps:
1 format file is : mm-day-year.dat
2 folder name ex: 2011
3 data accumulation is from 01-01-2011 to 1-30-2011 (a month from 12 month)
4 how to plot result data poin 3 with month. in a year
thanks

채택된 답변

per isakson
per isakson 2012년 7월 3일
편집: per isakson 2012년 7월 3일
This is a start
function cssm( folder_spec, file )
03:05:00 .000 065.501 01** 4864 0086 0074 +19 03:06:00 .000 065.501 01** 4862 0095 0074 +19 03:07:00 R- .026 065.501 01** 4862 0105 0074 +19 03:08:00 R- .180 065.504 01** 4864 0105 0074 +19
sad = dir( fullfile( folder_spec, file ) );
for sa = transpose( sad )
fid = fopen( fullfile( folder_spec, sa.name ), 'r' );
cac = textscan( fid, '%8c%2c%4f%7f%4c%4u%4u%4u+%2u' ...
, 'Delimiter', ' ', 'Whitespace', '' );
fclose( fid );
end
end
Try:
  • set break point at first line
  • run
cssm( 'c:\your_path\2011\', '*.dat' )
  • experiment in break mode with the actual data
  • add working lines of code to the function
  • save and restart function when it becomes messy
  댓글 수: 43
Soni huu
Soni huu 2012년 7월 4일
can u ceck my m file please(1kb). or can u upload your m file, coz i just have 19 line code and u have 28 line code
per isakson
per isakson 2012년 7월 4일
I downloaded your file and renamed it to "ReadSoniData_2.m" and I changed the name of the function to "ReadSoniData_2". Then I run
>> clear all
>> cac = ReadSoniData_2( 'h:\m\cssm', '11-02-2011.dat' );
>> plot( cac{3})
It worked without problems. The value of the peak is 60 plus.

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

추가 답변 (1개)

per isakson
per isakson 2012년 7월 4일
편집: per isakson 2012년 7월 4일
Next step, try:
>> dbstop ReadSoniData 2
>> cac = ReadSoniData( 'h:\m\cssm', '11-02-2011.dat' );
However, if you didn't watch Doug's video you might need to do that now. Then step through the code.
.
The data file, '11-02-2011.dat', shall be in your folder, 'C:\matlab7\work\org'.
You could add an assert to the file after "sad = dir(..."
sad = dir( fullfile( folder_spec, file ) );
assert( not( isempty( sad ) ) ...
, 'ReadSoniData:NoFileFound' ...
, 'Cannot find files matching "%s"' ...
, fullfile( folder_spec, file ) )
  댓글 수: 9
Soni huu
Soni huu 2012년 7월 4일
now how 30 file is work??
per isakson
per isakson 2012년 7월 4일
편집: per isakson 2012년 7월 4일
Hint: In the for-loop you need to assign the result, which you want to keep to an appropriate variable and make that new variable the output argument.
Case closed!

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by