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

3 ビュー (過去 30 日間)
Ana Bermejo Jimenez
Ana Bermejo Jimenez 2019 年 7 月 17 日
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 件のコメント
Akira Agata
Akira Agata 2019 年 7 月 18 日
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 2019 年 7 月 20 日
Thank You, that is exactky what I needed.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCalendar についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by