How to select the maximum points of the absolute values of a sin function

조회 수: 2 (최근 30일)
I would like to get all the maximum values of x in another matrix any idea? Sorry I am new
fs = 500;
t = 0:1/fs:10-1/fs;
x = abs(sin(2*pi*3*t));
  댓글 수: 1
Adam
Adam 2017년 8월 17일
편집: Adam 2017년 8월 17일
Due to discretisation and the imperfect reproduction of the sine wave you will only pick up certain peaks as being the maximum.
find( x == 1 )
will give the indices of these locations, but when I run it this gives me only every 3rd peak. If you want the actual peak locations of the continuous curve surely that is just trivial maths?
peakLocs = 1/12 : 1/6 : ( 10 - 1/fs );

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

채택된 답변

Torsten
Torsten 2017년 8월 17일
https://de.mathworks.com/help/signal/ref/findpeaks.html
Best wishes
Torsten.
  댓글 수: 2
Mauricio Galván García Luna
Mauricio Galván García Luna 2017년 8월 17일
thank you so much!!
But once I get the maximum points is there a way to put them back in the time that they belong.
Torsten
Torsten 2017년 8월 17일
편집: Torsten 2017년 8월 17일
[xp,locs] = findpeaks(x);
for i=1:numel(xp)
tp(i)=t(locs(i));
end
Best wishes
Torsten.

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

추가 답변 (1개)

Selva Karna
Selva Karna 2017년 8월 17일
fs = 500;
t = 0:1/fs:10-1/fs;
x = abs(sin(2*pi*3*t));
p=find(x==1)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by