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

1 次查看(过去 30 天)
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 个评论
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