Extracting repeated rows from table data based on conditions
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Levi Mallin
am 23 Mär. 2020
Kommentiert: Levi Mallin
am 24 Mär. 2020
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
0 Kommentare
Akzeptierte Antwort
Mohammad Sami
am 24 Mär. 2020
Bearbeitet: Mohammad Sami
am 24 Mär. 2020
% 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)),:)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!