managing year and months
조회 수: 1 (최근 30일)
이전 댓글 표시
i have dataset in following formay M = [2015 1 5 ; 2015 1 6 ; 2015 2 6 ; 2014 3 6 ; ]
split like this A = [2015 1 5 ; 2015 1 6 ; ]
B = [2015 2 6 ;]
C = [2014 3 6 ]
댓글 수: 0
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2015년 6월 12일
편집: Azzi Abdelmalek
2015년 6월 12일
Use cell arrays instead of creating several variables.
M = [2015 1 5 ; 2015 1 6 ; 2015 2 6 ; 2014 3 6 ];
v=M(:,1:2);
[ii,jj,kk]=unique(v,'rows','stable');
out=accumarray(kk,1:numel(kk),[],@(x) {M(x,:)});
celldisp(out);
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!