How do I find a maximum within a certain range

126 ビュー (過去 30 日間)
Milena
Milena 2022 年 9 月 29 日
回答済み: Davide Masiello 2022 年 9 月 29 日
I am currently trying to find the maximum of a signal, but I only want the max between 0.1 and 0.7, can anyone help?
I have been searching for an answer for a while now.
Thanks in advance!

回答 (2 件)

KSSV
KSSV 2022 年 9 月 29 日
編集済み: KSSV 2022 年 9 月 29 日
Let (x,y) be your data arrays.
idx = x>0.1 & x<0.7 ;
iwant = max(x(idx)) ;

Davide Masiello
Davide Masiello 2022 年 9 月 29 日
Take this example dataset
x = linspace(0,10,100);
y = randi(10,1,100).*sin(x);
plot(x,y)
Now assume you want to find the maximum between 6 and 10.
xs = x(x>=6 & x<=10);
ys = y(x>=6 & x<=10);
[~,idx] = max(ys);
hold on
plot(xs(idx),ys(idx),'or')

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by