I'm trying to find the indicator elements in a vector which corresponds to another vector, preferably loops without using. For example, my input may be:
DJiSet = [5 7 8]; % Elements in which I need index GSAT = [3 4 5 6 7 8 9 11 12 20];
will be here% vector to search:
[3 5 6]
The fastest I 'Has come up with:
output = search (ismember (gset, djset));
However, I feel that it can be faster, especially when I thought that Search
command is slow.
Note things to GST
Jisiti -
Dijiset
code > always sorted in ascending order without repeated entries - vector
DJiSet
to Jisiti
/ Ul>
approach # 1
you DJiSet
and < Find out the ismember
inside the code> GSET and locate and then use the second index, which we call the matching index
[~, outside] = ismember (DJiSet, JiSet)
/ P> The specific conditions set out in the question can be tried out of the afternoon's perspective, not sure whether it will be m ore efficient -
intv_idx = zero ( 1, number (DJiSet)); Intv_idx (1) = find (GESet == DJset (1), 1); Start = intv_idx (1) +1; K = 2: numel (DJiSet) idx = find (GSAT (start: end) == DJiSet (k), 1); Start = idx + start; Intv_idx (k) = idx; End = cumsum (intv_idx);
No comments:
Post a Comment