How do I get the row numbers of the 'list' where the values are equal to the values of the array 'days'
2 次查看(过去 30 天)
显示 更早的评论
%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 个评论
采纳的回答
Robert U
2019-10-17
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!