How to remove some data from the plot?

2 ビュー (過去 30 日間)
Lukasz Zaczek
Lukasz Zaczek 2021 年 2 月 7 日
回答済み: David Hill 2021 年 2 月 7 日
Hi, I would like to remove this values from my plot.
I think that to achieve this, 2 conditions are needed:
  • Each value cannot be greater than the previous one.
  • The next value cannot differ from the previous one by more than | 40 |.
  • After removing the value, the next one should be compared with the last one, that meets the above conditions.
I tried the loop in which the unwanted values were replaced by NaN, but then the last condition wasn't met, and morover there is no continuity of the graph in this case.

採用された回答

David Hill
David Hill 2021 年 2 月 7 日
a=yourArray;
k=2;
while k<=length(a)
if a(k)<=a(k-1)&&a(k)+40>a(k-1)
k=k+1;
else
a(k)=[];
end
end

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by