Finding Patterns in Array

4 ビュー (過去 30 日間)
Connor O'Higgins
Connor O'Higgins 2018 年 1 月 26 日
コメント済み: Connor O'Higgins 2018 年 1 月 29 日
Hi, I am currently using the 'findpattern' function (which can be found here ) to find patterns in temperature data.
e.g. find the index when temperature was at 10 degrees for 2 hours. in this case my pattern would be [10 10 10 10 ...] and findpattern.m would find the index in the start value. My temperature data was taken every 5 min which dictates the length of the pattern.
I would like to have a range of temperatures instead of 1 value i.e. find the locations when temperature was anywhere between 9 and 11 degrees for 2 hours.
  2 件のコメント
Stephen23
Stephen23 2018 年 1 月 26 日
@Connor O'Higgins: what is your question?
Connor O'Higgins
Connor O'Higgins 2018 年 1 月 26 日
Sorry, that wasn't well explained
I need to find the locations in my temperature data where the temperature has been steady for several hours.
However, this temperature should be in a range i.e. 9 to 11 degrees.

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

採用された回答

Guillaume
Guillaume 2018 年 1 月 26 日
%T: temperature vector
%desiredduration: number of samples where temperature must be between 9 and 11
inrange = T>=9 & T<= 11;
transitions = diff([false; inrange; false]); %find where the temperature change between in range/not in range occur
inrangestarts = find(transitions == 1);
inrangeends = find(transitions == -1);
inrangeduration = inrangeends - inrangestarts; %may be off by 1. Check
locs = inrangestarts(inrangeduration > desiredduration)
  1 件のコメント
Connor O'Higgins
Connor O'Higgins 2018 年 1 月 29 日
Thanks Guillaume, That does the job. The 'inrangeduration' did need a +1 like you said.

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2018 年 1 月 26 日
Attach your data or image. If you have a known pattern you're looking for, rather than trying to guess at patterns and finding some pattern that might be repeated somewhere, then you can use normxcorr2(). A demo is attached.

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by