How do I take a large table, split it into smaller chunks, and add them to a new table?
    조회 수: 2 (최근 30일)
  
       이전 댓글 표시
    
Hi, I have a 100x5 table. The 100 rows are split evenly into 4 classes (for example, 1:25 = class 1, 26:50 = class 2, and so on). I would like to take the first 10 value from each of the classes in that table to create a new, 40x5 table. Is this possible? This is the code I have now, but it is not set up correctly. Any help is appreciated.
Table40 = Table100([1:10,:],[26:35,:],[51:60,:],[76:85,:]);
댓글 수: 0
답변 (2개)
  Star Strider
      
      
 2017년 7월 14일
        Try this:
v1 = rand(100,1);                                   % Create Data
v2 = rand(100,1);                                   % Create Data
v3 = rand(100,1);                                   % Create Data
v4 = rand(100,1);                                   % Create Data
v5 = rand(100,1);                                   % Create Data
Table100 = table(v1, v2, v3, v4, v5);               % Create ‘Table100’
Table40 = Table100([1:25,26:35,51:60,76:85],:);     % Create ‘Table40’
댓글 수: 0
  Peter Perkins
    
 2017년 7월 18일
        Another possibility: use repelem to create a variable in the table that indicates the group number. Then call varfun, using that new variabl;e as the grouping variable, and pass varfun a function that returns the first 10 rows of whatever column vector it's given.
댓글 수: 0
참고 항목
카테고리
				Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


