Sudden changes in data values - how to detect?

17 ビュー (過去 30 日間)
James Wright
James Wright 2015 年 2 月 25 日
回答済み: Steven Lord 2022 年 11 月 2 日
I have a matrix of data with around 2000 rows and only 1 column. They first few hundred are all numerical values between 1-10 and then all of a sudden, there is a change in the values to numbers between 1000-10000. How could i write a code to find the position in which this change occurs? I have been stuck with the question for several days and i can't think of a logical way to do it. I am extremely new to matlab.
Thank you

採用された回答

Star Strider
Star Strider 2015 年 2 月 25 日
The easiest way:
x = [randi(10, 20, 1); randi([1000 10000], 20, 1)]; % Created Data
jump = find(diff([0; x]) > 10, 1, 'first'); % Index
The ‘jump’ variable has the first index of the difference in the values that is greater than 10. Run my simulated code — and experiment with it to see how it works — then apply it to your vector.
  4 件のコメント
RobB
RobB 2015 年 6 月 8 日
This could help me, but is it possible to show the location of multiple changes? Say you had several large jumps in one column of data...is it possible to have matlab tell us more than just the first location? Thanks!
Star Strider
Star Strider 2015 年 6 月 8 日
Yes.
See my Comment to dpb’s Answer in your original Question.

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2022 年 11 月 2 日
Since this question was asked the ischange function has been added to MATLAB. Its short description is "Find abrupt changes in data".

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by