How do I write a code to filter catalogs by...
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I want to filter two catalogs that contain the dates of certain events. I want to check to see if catalog one has any events that occurred within the same time frame as the entirety of catalog two. Seems simple enough.
Can anyone move me in the right direction on this? I'm a little new to matlab.
I know how to use matlabdate too.
0 Commenti
Risposte (1)
Star Strider
il 1 Lug 2014
If they’re simply lists of dates (and perhaps times), I would convert them to date numbers (datenum) and use the intersect function.
2 Commenti
Star Strider
il 1 Lug 2014
The intersect function will only include values that are exactly the same.
I chose a deliberately difficult situation to illustrate an alternative approach, but it depends on how your data are organised between the catalogs. You might want to experiment with something like this to see if it gives you the result you want:
C1 = unique(randi(50, 1, 25)); % Test Data
C2 = unique(randi(50, 1, 25)); % Test Data
for k1 = 1:length(C1)
Ci(k1,:) = find(C2 <= C1(k1), 1, 'last');
end
It loops through the values of C1 (Catalog #1) and tests the entries in C2 to see what the greatest value in C2 is that is less than or equal to the particular entry for C1. It returns the indices of the entries in C2 (in vector Ci) that meet those criteria.
This code snippet works, but I can’t determine if it is appropriate to your data.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!