フィルターのクリア

Estimate the maximum value among three consecutive values in a vector

1 回表示 (過去 30 日間)
Hello, I need to do some calculation on each value for each vector. For example, the vector A may contain hundreds of acceleration values:
A=[0.18, 0.01, -0.15, 0.08, .25, 0.12, ......]
I need to abtain a new vector which contains the max value of each three consecutive values of the vector like this:
B=[max(0.18,0.01,-0.15), max(0.01, -0.15,0.08), max(-0.15,0.08,0.25) ...... end=length signal(A)]
I would appreciate your help
Best

採用された回答

the cyclist
the cyclist 2023 年 7 月 17 日
A=[0.18, 0.01, -0.15, 0.08, .25, 0.12];
output = movmax(A,3)
output = 1×6
0.1800 0.1800 0.0800 0.2500 0.2500 0.2500
  2 件のコメント
the cyclist
the cyclist 2023 年 7 月 17 日
Note that @Dyuman Joshi's answer illustrates that the movmax function accepts arguments that will affect how you want to handle the endpoints.
Jorge Luis Paredes Estacio
Jorge Luis Paredes Estacio 2023 年 7 月 17 日
Thank you very much. It works

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

その他の回答 (1 件)

Dyuman Joshi
Dyuman Joshi 2023 年 7 月 17 日
%Random data for example
x = 1:10;
y = movmax(x,3,'Endpoints','discard')
y = 1×8
3 4 5 6 7 8 9 10

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by