Extracting repeated rows from table data based on conditions

I currently have the following table... where 'speed' and 'temp' columns can only have a value of '1' or '2'.
I am wanting to extract rows that have identical values for the first 5 columns (Ric, int_1, Rmd, int_2, Roo) but only if they appear for all combinations of the last two columns (speed, temp).
For the table above, there are 4 combinations of speed and temp (1 1; 1 2; 2 1; 2 2). Only rows 3-6 and 10-13 have identical values for all 4 combinations so my output table would be...
How could I do this?
Thanks

 채택된 답변

Mohammad Sami
Mohammad Sami 2020년 3월 24일
편집: Mohammad Sami 2020년 3월 24일
% a = sometable, % assume no repeat of columns 6:7 for combination of 1:5
[b,ia,ic] = unique(a(:,1:5),'rows');
n = accumarray(ic,ic,[],@length);
out = a(ismember(ic,find(n==4)),:)

댓글 수: 1

Perfect! Thanks for the quick response. Now just to work out how that all works...

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 3월 23일

댓글:

2020년 3월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by