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

2 visualizaciones (últimos 30 días)
Soni huu
Soni huu el 3 de Jul. de 2012
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

Respuesta aceptada

per isakson
per isakson el 3 de Jul. de 2012
Editada: per isakson el 3 de Jul. de 2012
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 comentarios
Soni huu
Soni huu el 4 de Jul. de 2012
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 el 4 de Jul. de 2012
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.

Iniciar sesión para comentar.

Más respuestas (1)

per isakson
per isakson el 4 de Jul. de 2012
Editada: per isakson el 4 de Jul. de 2012
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 comentarios
Soni huu
Soni huu el 4 de Jul. de 2012
now how 30 file is work??
per isakson
per isakson el 4 de Jul. de 2012
Editada: per isakson el 4 de Jul. de 2012
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!

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by