フィルターのクリア

"Squeeze" array of indexes.

1 回表示 (過去 30 日間)
Adam
Adam 2011 年 8 月 4 日
There must be an elegant way to do this in MATLAB.
Let's say I have an array of points and I want to find all areas where the points are over 0.90.
gap_indexes = find(output > 0.90)
Now you have indexes to all locations where output is greater than 0.90. But let's say you don't care about when there are two 0.90s right next to each other. What's the best way to squeeze them out into 1 index (let's say the later index)?
  1 件のコメント
the cyclist
the cyclist 2011 年 8 月 4 日
I think it would be a good idea for you to give a specific example of the variable "output" (which is your input!), and what you prefer to see for gap_indexes.

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

回答 (2 件)

Oleg Komarov
Oleg Komarov 2011 年 8 月 4 日
% Run length encoding:
A = rand(100,1)>.9;
find(diff([A; false]) == -1)
If you want the first change -1 to 1.

Adam
Adam 2011 年 8 月 9 日
Thanks for help. Will respond with my solution when I have time in the future.

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by