How do I write a code to filter catalogs by...

2 次查看(过去 30 天)
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.

回答(1 个)

Star Strider
Star Strider 2014-7-1
If they’re simply lists of dates (and perhaps times), I would convert them to date numbers (datenum) and use the intersect function.
  2 个评论
Shane
Shane 2014-7-1
What if a date in catalog 1 is between two values in catalog 2, but I still want to flag it? Does intersect only flag values that are exactly the same value as each other?
Star Strider
Star Strider 2014-7-1
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by