How do I get the row numbers of the 'list' where the values are equal to the values of the array 'days'
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Catalytic Kys
el 17 de Oct. de 2019
Comentada: Catalytic Kys
el 17 de Oct. de 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 comentarios
Respuesta aceptada
Robert U
el 17 de Oct. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrices and Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!