find local max in time window

조회 수: 1 (최근 30일)
Hasan alomari
Hasan alomari 2017년 4월 26일
답변: Hasan alomari 2017년 5월 5일
am trying to find the local max in time window , i know that I have to define part from the signal then use the findpeaks built in function then take the max value of it.
% code
pks_value=[];this to store the max value from the peaks
step=200;
pcg=pcg_lp2';
for i=1:200:N
temp=pcg(i:i+step);
[pks,locs] = findpeaks(temp);
pks_value(i)=max(pks);
end
it give me the error msg "Index exceeds matrix dimensions. " so how to fix it , what to change

채택된 답변

Greg Dionne
Greg Dionne 2017년 5월 2일
If you have a recent copy of MATLAB, try using movmax().
  댓글 수: 2
Hasan alomari
Hasan alomari 2017년 5월 4일
it will give the max value but without the location
Greg Dionne
Greg Dionne 2017년 5월 4일
This should get you started:
x = randi(10,150,1);
tmp = movmax(x,5);
imvmax = find(x==tmp);
mvmax = x(imvmax);
plot(1:length(x),x,'-',imvmax,mvmax,'o')

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Hasan alomari
Hasan alomari 2017년 5월 5일
thank you i did it using the max which also return the value and the location, but will try this also to see if I will obtain the same result

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by