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

1 回表示 (過去 30 日間)
Shane
Shane 2014 年 7 月 1 日
コメント済み: Star Strider 2014 年 7 月 1 日
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 Center および File ExchangeMatched 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