フィルターのクリア

Finding all consecutive numbers of different lengths within a vector

1 回表示 (過去 30 日間)
BobbyRoberts
BobbyRoberts 2020 年 4 月 29 日
コメント済み: BobbyRoberts 2020 年 4 月 29 日
I am trying to create a new vector based on the example vector below. This new vector needs to contain only the first value of each group of consecutive numbers. For example, from the vector below, I would want a new vector X that contains [25 55 80 100 155]. Thanks for the help in advance!
A = [25 26 27 28 55 56 80 81 82 100 101 102 103 104 105 155 156]

採用された回答

Stephen23
Stephen23 2020 年 4 月 29 日
>> A = [25,26,27,28,55,56,80,81,82,100,101,102,103,104,105,155,156];
>> X = A([true,diff(A)~=1])
X =
25 55 80 100 155

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by