'For ' loop for every day for one minut fequency sea level data
Show older comments
(01). I have 12 years of 1 min frequency sea level data (six million rows). I need to save min and max within a every day (60*24) as a different text files using all 12 years. (02). Same thing within 14 days to save min and max values as different files in 12 years (60*24*14). Drafted code here with. It is working but mean value for min and max shows wrong. The each min and max files only consisted 30 values, but it have 1440 rows. 07/01/2018 00:00,1.027 07/01/2018 00:01,1.034 07/01/2018 00:02,1.047 07/01/2018 00:03,1.026 07/01/2018 00:04,1.031 07/01/2018 00:05,1.057
Accepted Answer
More Answers (1)
Akira Agata
on 9 Sep 2018
Edited: Akira Agata
on 9 Sep 2018
I would recommend storing your data in timetable variable, and apply retime function to do your task. Following is an example.
% Read data file and convert to timetable
T = readtable('july2018.txt', 'Format', '%{MM/dd/yyyy HH:mm}D%f');
T.Properties.VariableNames = {'time','value'};
TT = table2timetable(T);
% min and max within a day
Tmin_1d = retime(TT,'daily','min');
Tmax_1d = retime(TT,'daily','max');
% Same thing within 14 days to save min and max
t1 = TT.time(1):days(14):TT.time(end);
Tmin_14d = retime(TT,t1,'min');
Tmax_14d = retime(TT,t1,'max');
3 Comments
indika kathaluwa weligamage
on 10 Sep 2018
Edited: indika kathaluwa weligamage
on 10 Sep 2018
Akira Agata
on 12 Sep 2018
That's a relatively easy part. MATLAB has writetable function for this task. To save the result in file, please try following.
Tmin_1d.time.Format = 'MM/dd/yyyy';
writetable(timetable2table(Tmin_1d),'Tmin_1d.csv');
And to plot the result, you can use plot function, such as:
figure
plot(Tmin_1d.time,Tmin_1d.value,'o-')
indika kathaluwa weligamage
on 13 Sep 2018
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!