How do I get the row numbers of the 'list' where the values are equal to the values of the array 'days'
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Catalytic Kys
il 17 Ott 2019
Commentato: Catalytic Kys
il 17 Ott 2019
%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),:);
[days] = out(:,1);
0 Commenti
Risposta accettata
Robert U
il 17 Ott 2019
Hi Yannick Leroy,
the function ismember() allows to compare matrices with vector elements. The function find() supplies the indices. You don't need to use find() if you can utilize logical indexing.
[ind,~] = find(ismember(list,days)) % find row index only
ind = unique(ind); % remove duplicates
Kind regards,
Robert
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrices and Arrays in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!