How can I separate individual years from a timetable?
조회 수: 5 (최근 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!