Find max/min while ignoring data spikes

10 ビュー (過去 30 日間)
Marcus Solis
Marcus Solis 2017 年 6 月 14 日
コメント済み: Marcus Solis 2017 年 6 月 15 日
My problem is that I want to ignore the sudden dropoff in the attached plot. I'm using the following to get the minimum and maximum:
ErrPriMax = ErrorPri<1;
ErrorPriMax = max(ErrorPri(ErrPriMax));
ErrPriMin = ErrorPri>-.4;
ErrorPriMin = min(ErrorPri(ErrPriMin));
ErrRedMax = ErrorRed<1;
ErrorRedMax = max(ErrorRed(ErrRedMax));
ErrRedMin = ErrorRed>-.4;
ErrorRedMin = min(ErrorRed(ErrRedMin));
The correct minimums should be around -.2 for the primary error and -.05 for the redundant error; however, I am getting around -.4 for both since that is the hard limit I coded in. Is there a better way to do this? I essentially want to ignore the two spikes.
ErrorPri and ErrorRed are the datasets I am working with along with Time. They dont go to infinite, they go more closely to -20 (which is far greater than reality).
Any help is greatly appreciated.
Thank You!

回答 (1 件)

JohnGalt
JohnGalt 2017 年 6 月 15 日
it looks like '-1' is some specific value which you want to ignore... so you remove all '-1's from the array before you calculate the min e.g.
testArray = [.1 .2. -.1 .2 .1 .2 -1 .2. .1];
testArray(testArray<=-1)==[];
disp(testArray) % which will be: [.1 .2. .1 .2 .1 .2 .2. .1];
disp(min(testArray)) % which will be -.1
Just be aware that you have removed a point from your original array so you have changed the length of the original
  1 件のコメント
Marcus Solis
Marcus Solis 2017 年 6 月 15 日
The only problem with that is that the data goes to -1. So the array looks more like [-0.87 -0.91 -0.95 -0.97 -0.99 -1.02...]. So when I add a filter like the one you have above, the min is going to be -0.99. I was thinking that I could take the derivative, and if it goes close to infinity then I know there is a spike. But even doing that I would have to compare the derivative across 30 to 50 points.

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by