How to separate each day of this file?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mohamed Nedal
el 17 de En. de 2019
Comentada: Mohamed Nedal
el 9 de En. de 2020
Hello,
Kindly find the attached text file. It contains data for the entire January 2014.
Each row represents a data record per hour so that it starts from hour=0 (the 3rd column) to hour=23 and then starts again from hour=0 for the next day, and so on.
I need to loop over the rows and save each day (24 hours; rows) separately in a text file (i.e. d1, d2, ..., d31).
Could you please tell me how to do that?
Thanks in advance.
0 comentarios
Respuesta aceptada
madhan ravi
el 17 de En. de 2019
Editada: madhan ravi
el 17 de En. de 2019
https://www.mathworks.com/help/matlab/ref/dlmwrite.html?searchHighlight=dlmwrite&s_tid=doc_srchtitle#btzp57u-1 - adapt precision which suits you the best
T=load('Jan.txt');
TT=mat2cell(T,repmat(24,numel(unique(T(:,2))),1));
for i = 1:numel(unique(T(:,2)))
dlmwrite(sprintf('file%d',i),TT{i},'precision','%.2f','delimiter',' ') % saves each day in a separate file , filenames will be like file1.txt ... and so on till the end
end
4 comentarios
Más respuestas (0)
Ver también
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!