# Interval where values are greater than treshold

1 ビュー (過去 30 日間)
Lucas Russi 2019 年 12 月 10 日
Commented: Lucas Russi 2019 年 12 月 10 日
Hi everyone
Logic = Data > Treshold
I now need to know what the intervals are where the treshold is exceeded
Logic = [1 1 1 0 0 0 1 1 0 1]
Desired_Output = [1 3;7 8;10 10]
So - from 1 to 3, from 7 to 8 aswell as 10
I can't think of a good way to do this.

#### 0 件のコメント

サインイン to comment.

### 採用された回答

Stephen Cobeldick 2019 年 12 月 10 日
>> B = find([true;diff(Logic(:))>0]);
>> E = find([diff(Logic(:))<0;true]);
>> M = [B,E]
M =
1 3
7 8
10 10

#### 1 件のコメント

Lucas Russi 2019 年 12 月 10 日
gracias <3

サインイン to comment.

Jeremy Marcyoniak 2019 年 12 月 10 日
I believe you are looking for the find command.
find(Logic)

#### 3 件のコメント

Lucas Russi 2019 年 12 月 10 日
find(Logic) = [1 2 3 7 8 10]
not exactly - I'm aware of find; there's one more step to get to what I put as my desired Output .. and there's the issue
Jeremy Marcyoniak 2019 年 12 月 10 日
You could use
diff
to determine adjacent numbers and drop the intermediate numbers appropriately
Lucas Russi 2019 年 12 月 10 日
Thanks for participating :)
idx = find(Logic)
idx(end+1) = 0
idx(diff(idx) ~= 1)
would be the indices that mark the end of the interval - but what about the start ?

サインイン to comment.

サインイン してこの質問に回答します。

Translated by