Find exact vector order in another vector array
Afficher commentaires plus anciens
I am trying to find a way to grab indivdual cells within a cell array that I can then use to find the exact order found in a larger matrix array.
I am having a difficult time trying to find a way to grab the exact order/vector in each cell array to locate the indices in the second larger matrix array.
For example, my cell array "att_event_codes" is the array I'm grabbing my desired vectors to find in the larger matrix array:
att_event_codes{1,1} : 9 10 12 11 20 12 33 21 42 22 18
att_event_codes{1,2}: 9 10 12 11 20 12 33 21 40 41 22 18
If I grab, for example, att_event_codes{1,1} as a vector I want to use:
vector = (att_event_codes{1,1});
I want to take that vector assignment to find the exact order of event codes in my larger matrix called "event_codes" (1x19277 double).
I have tried several matlab functions such as find, ismember, and strcmp and have been unable to figure out how to get them to work taking into account the entire vector rather than working with individual items within the vector. For example:
vector = (att_event_codes{1,1});
mask = ismember(event_codes,vector);
test = find(mask)
test returns 1x14953 double
Another way that I've tried (which is probably a better way to do this):
[~,test] = ismember(vector, event_codes)
test returns 1x11 double:
1 2 3 8 4 3 25 11 3655 5 15
The correct (desired) answser for this "test" would return an index of 3647:3657.
Thank you.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Large Files and Big Data dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!