How can I separate individual years from a timetable?
    3 views (last 30 days)
  
       Show older comments
    
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 Comments
Accepted Answer
  Stephen23
      
      
 on 6 Mar 2023
        
      Edited: Stephen23
      
      
 on 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 Comments
  Stephen23
      
      
 on 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)
More Answers (0)
See Also
Categories
				Find more on Logical in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

