How do I compare 'list' with 'out' to check where both values of a row for 'out' are equal to both values of a row for 'list'?

1 view (last 30 days)
clear;
close all;
clc;
list = [
50 74;
6 34;
147 162;
120 127;
98 127;
120 136;
53 68;
145 166;
95 106;
242 243;
222 250;
204 207;
69 79;
183 187;
198 201;
184 199;
223 245;
264 291;
100 121;
61 61;
232 247;
153 181;
197 216;
283 307;
194 199;
82 109;
10 25;
60 90;
256 271;
172 173;
];
M = sortrows(list);
out = M(sum(squeeze(any(M - permute(M,[3,2,1]) <= 0,2))) == 1:size(list,1),:);

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 17 Oct 2019
Edited: KALYAN ACHARJYA on 17 Oct 2019
idx=find(list==out);
You will get the all rows value, where "list" rows value equal to "out" rows elements.
As per the question, the list size is 30x2, whereas out size is 16x2, hence it can not be directly compare with differenent matrices having unequal sizes. Hence I have trimmed the "list" matrics (First 16 rows considerd) to show the result-
list = [50 74;6 34;147 162;120 127;98 127;120 136;53 68;145 166;95 106;242 243;222 250;204 207;69 79;
183 187;198 201;184 199;223 245;264 291;100 121;61 61;232 247;153 181;197 216;283 307;194 199;82 109;
10 25;60 90;256 271;172 173]
M=sortrows(list);
out = M(sum(squeeze(any(M - permute(M,[3,2,1]) <= 0,2))) == 1:size(list,1),:)
idx=find(list(1:16,:)==out)

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!