How can I take out months rows from each year.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
g
0 commentaires
Réponses (2)
Hiro Yoshino
le 10 Fév 2020
d = ['190101'; '190201'; '190301']; % sample data
d_datetime = datetime(d, 'InputFormat', 'yyMMdd'); % change format to datetime
[y,m,d] = ymd(d_datetime); % break it into pieces
idx = m == 1 | m == 2; % extract the indices corresponding to Jan and Feb. You can add " | m == 12 " to extract December!
Please take a look at this. I belive this is applicable to your problem.
2 commentaires
Image Analyst
le 10 Fév 2020
Then
yourTable = yourTable(~idx, :); % Extract all rows EXCEPT rows identified by idx.
Hiro Yoshino
le 10 Fév 2020
Modifié(e) : Hiro Yoshino
le 10 Fév 2020
I guess your date is not read as string.
tableData = readtable('yourExcel.xlsx');
tableData.Time = string(tableData.Time);
Then you can start from
d_datetime = datetime(tableData.Time, 'InputFormat', 'yyMMdd'); % change format to datetime
2 commentaires
Hiro Yoshino
le 10 Fév 2020
[y,m,d] = ymd(d_datetime); % break it into pieces
idx = m == 1 | m == 2; % extract the indices corresponding to Jan
Do not forget these lines!! Good luck! almost there.
Voir également
Catégories
En savoir plus sur Dates and Time 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!