How can I separate individual years from a timetable?
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephen23
2023-3-6
编辑:Stephen23
2023-3-6
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 个评论
Stephen23
2023-3-7
S = load('DateStamp.mat');
T = S.DateStamp
[G,Y] = findgroups(T.date.Year);
N = accumarray(G,ones(size(G)));
bar(Y,N)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!