How can I separate individual years from a timetable?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi!
I have one table that contains 764 rows with different year's data point from 1984 to 2022. For example, row 1 to 8 are for 1984, row 9 to 14 are for 1985, row 15 to 24 are for 1986 and so on.
Can anyone please tell me how to create a cell array where I can have the indices for the individual year?
i.e., {year_list} = {[1:8];[9:14];[15:24],....} etc.
I have added the table in this question. Any feedback will be greatly appreciated!!
0 commentaires
Réponse acceptée
Stephen23
le 6 Mar 2023
Modifié(e) : Stephen23
le 6 Mar 2023
S = load('DateStamp.mat')
T = S.DateStamp
[G,Y] = findgroups(T.date.Year);
X = arrayfun(@(x)find(x==G), 1:max(G), 'uni',0);
These are the years:
Y
and the corresponding indices:
X
X{1:3}
See also:
4 commentaires
Stephen23
le 7 Mar 2023
S = load('DateStamp.mat');
T = S.DateStamp
[G,Y] = findgroups(T.date.Year);
N = accumarray(G,ones(size(G)));
bar(Y,N)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Descriptive Statistics 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!