Main Content

데이터에서 피크 찾기

findpeaks를 사용하여 데이터 세트에서 국소 최댓값에 해당하는 값과 위치를 찾습니다.

파일spots_num.mat에는 1749년부터 2012년까지 매년 관측된 태양 흑점의 평균 개수가 포함되어 있습니다. 이 데이터는 NASA에서 제공되었습니다.

최댓값과 최댓값이 나타난 연도를 찾습니다. 데이터와 함께 이렇게 찾은 항목을 플로팅합니다.

load('spots_num.mat') [pks,locs] = findpeaks(avSpots); plot(year,avSpots,year(locs),pks,'or') xlabel(“年”) ylabel('Number') axistight

Figure contains an axes object. The axes object contains 2 objects of type line.

일부 피크는 서로 매우 가깝게 있습니다. 나머지 피크는 규칙적인 간격으로 다시 나타납니다. 50년 주기당 5개 정도의 피크가 있습니다.

주기 길이를 더욱 효과적으로 추정하려면findpeaks를 다시 사용하되, 이번에는 피크 간 간격을 최소 6년으로 제한합니다. 최댓값 간의 평균 구간을 계산합니다.

[pks,locs] = findpeaks(avSpots,'MinPeakDistance',6); plot(year,avSpots,year(locs),pks,'or') xlabel(“年”) ylabel('Number') title('Sunspots') axistightlegend('Data','peaks','Location','NorthWest')

Figure contains an axes object. The axes object with title Sunspots contains 2 objects of type line. These objects represent Data, peaks.

cycles = diff(locs); meanCycle = mean(cycles)
meanCycle = 10.8696

태양 활동은 대략 11년을 주기로 순환하는 것으로 잘 알려져 있습니다. 푸리에 변환을 사용하여 확인해 보겠습니다. 신호의 평균을 제거하여 변동 부분에 집중합니다. 이 샘플 레이트는 수년 동안 측정되었다는 것에 유의하십시오. 주파수는 나이퀴스트 주파수 이하만 사용합니다.

Fs = 1; Nf = 512; df = Fs/Nf; f = 0:df:Fs/2-df; trSpots = fftshift(fft(avSpots-mean(avSpots),Nf)); dBspots = 20*log10(abs(trSpots(Nf/2+1:Nf))); yaxis = [20 85]; plot(f,dBspots,1./[meanCycle meanCycle],yaxis) xlabel(的频率(年^ {1})) ylabel('| FFT | (dB)') axis([0 1/2 yaxis]) text(1/meanCycle + .02,25,['<== 1/'num2str(meanCycle)])

Figure contains an axes object. The axes object contains 3 objects of type line, text.

실제로 푸리에 변환 시 예상된 주파수에서 피크에 도달했으며 이로써 11년이라는 추측이 사실임이 확인되었습니다. 푸리에 변환의 최고 피크를 찾는 방식으로 주기를 찾을 수도 있습니다.

[pk,MaxFreq] = findpeaks(dBspots,'NPeaks',1,'SortStr','descend'); Period = 1/f(MaxFreq)
Period = 10.8936
holdonplot(f(MaxFreq),pk,'or') holdofflegend('Fourier transform','1/meanCycle','1/Period')

Figure contains an axes object. The axes object contains 4 objects of type line, text. These objects represent Fourier transform, 1/meanCycle, 1/Period.

두 추정값이 거의 일치합니다.

참고 항목

|

관련 항목