1

我从测量文件中提取了一个序列,序列如下所示。

a=[2 1 3 2 1 0 1 2 3 4 5 4 3 2 3 4 5 4];

我想找到每个递减序列的起始索引....例如:在上面的序列中,您可以发现序列在以下索引处开始递减

 1.  [3 2 1] this sequence starts decreasing from the index 3,
 2.  [5 4 3 2] this sequence starts decreasing from the index 11,
 3.  [5 4] this sequence starts decreasing from the index 17.

关于如何找到这个序列起点的任何想法都会更有用......在此先感谢

4

1 回答 1

2

怎么样:

find(diff([0, diff(a) < 0]) == 1)

换句话说,找到差值为负 ( diff(a) < 0) 的索引位置,然后只选择那些在增加的数字之后出现的位置。

于 2013-10-29T14:37:47.933 回答