timerange for a given month during different years in a set of data

1 vue (au cours des 30 derniers jours)
Ana Bermejo Jimenez
Ana Bermejo Jimenez le 17 Juil 2019
Hi,
I am quite new to MATLAB and I am having some trouble making my code to work. I would appreciate very much your answers.
I have a set of data (data.mat) which contains 7 colums of data, being the first one the date (Jan 2010 to Dec 2019).
I would like to extract the data by months (for example all January months along 2010 and 2019).
I have used this solution to do it manually (I only add for 2 years in the example below)
e= table2timetable(data)
S = timerange ('01/01/2010','02/01/2010');
TT =e (S,:);
S1 = timerange ('01/01/2011','02/01/2011');
TT1=e(S1,:)
Jan = [TT;TT1];
I would like to make a loop over the data to just input years and month. Note that wm01ALL1 is my table with 2010 to 2019 data (data)
years = [2010 2011 2012 2013 2014 2015 2016 2017 2018 2019];
month = 6;
TTa shows the data for June of the last year in the loop instead of the stored data for each year.
  4 commentaires
Akira Agata
Akira Agata le 18 Juil 2019
It's not clear for me what you want to do in your task.
But anyway, if you want to extract specific month ( e.g January ) over many years, you can simply do that by following way.
% Extract January data from a timetable TT
idx = TT.Time.Month == 1;
TT_Jan = TT(idx,:);
Ana Bermejo Jimenez
Ana Bermejo Jimenez le 20 Juil 2019
Thank You, that is exactky what I needed.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Calendar dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by