Extracting rows from a matrix based on values in columns

 채택된 답변

Guillaume
Guillaume 2017년 10월 8일
It's much easier to do this with the newer splitapply rather than the older accumarray:
A = [[1;1;3;2;3;1], rand(6, 3)]
C = splitapply(@(rows) {rows}, A(:, 2:end), A(:, 1))

댓글 수: 2

I am up-voting even though ...
;)
Awesome, thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

for n=2:4, C_temp(:,n-1) = accumarray(A(:,1),A(:,n),[],@(n){n}); end
for m=1:size(C_temp,1), C{m} = cell2mat(C_temp(m,:)); end

카테고리

도움말 센터File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

태그

질문:

2017년 10월 8일

댓글:

2017년 10월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by