フィルターのクリア

How to filter data?

3 ビュー (過去 30 日間)
Thor
Thor 2013 年 1 月 16 日
Dear all,
I want to filter a matrix by its date vector. The datevector has the format: dd.mm.yyyy HH:MM:SS. I want to sum up all the data with the same month and year. How can I do that?

採用された回答

Jan
Jan 2013 年 1 月 16 日
dateAsString = {'31.02.2013 11:22:33'; '31.05.2013 11:22:33'}
dateAsVector = datevec(datestr, 'dd.mm.yyyy HH:MM:SS');
yearAndMonth = 100 * dateAsVector(:, 1) + dateAsVector(:, 2);
Now you get values like [201302, 201305] and summing can be done by accumarray directly.
  2 件のコメント
Walter Roberson
Walter Roberson 2013 年 1 月 16 日
You would probably not want to use those values as direct subscripts into accumarray: you would probably want to unique() them and use the indices. Otherwise your array is going to end up being up to 240000 long with not many entries used.
Jan
Jan 2013 年 1 月 16 日
You are right, Walter, and even for a FOR loop approach using the indices obtained by UNIQUE is better.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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