Main Content

데이터에서 피크 찾기

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

파일 spots_num에는 1749년부터 2012년까지 매년 관측된 태양 흑점의 평균 개수가 포함되어 있습니다. 최댓값과 최댓값이 나타난 연도를 찾습니다. 데이터와 함께 이렇게 찾은 항목을 플로팅합니다.

load("spots_num")

[pks,locs] = findpeaks(avSpots);

plot(year,avSpots,year(locs),pks,"o")
xlabel("Year")
ylabel("Sunspot Number")
axis tight

Figure contains an axes object. The axes object with xlabel Year, ylabel Sunspot Number contains 2 objects of type line. One or more of the lines displays its values using only markers

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

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

[pks,locs] = findpeaks(avSpots,MinPeakDistance=6);

plot(year,avSpots,year(locs),pks,"o")
xlabel("Year")
ylabel("Sunspot Number")
axis tight
legend(["Data" "peaks"],Location="NorthWest")

Figure contains an axes object. The axes object with xlabel Year, ylabel Sunspot Number contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent Data, peaks.

meanCycle = mean(diff(locs))
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 = mag2db(abs(trSpots(Nf/2+1:Nf)));

plot(f,dBspots)
xline(1/meanCycle,Color="#77AC30")
xlabel("Frequency (year^{-1})")
ylabel("| FFT | (dB)")
ylim([20 85])
text(1/meanCycle + 0.02,25,"<== 1/"+num2str(meanCycle))

Figure contains an axes object. The axes object with xlabel Frequency (year toThePowerOf - 1 baseline ), ylabel | FFT | (dB) contains 3 objects of type line, constantline, text.

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

[pk,MaxFreq] = findpeaks(dBspots,NPeaks=1,SortStr="descend");

Period = 1/f(MaxFreq)
Period = 10.8936
hold on
plot(f(MaxFreq),pk,"o")
hold off
legend(["Fourier transform" "1/meanCycle" "1/Period"])

Figure contains an axes object. The axes object with xlabel Frequency (year toThePowerOf - 1 baseline ), ylabel | FFT | (dB) contains 4 objects of type line, constantline, text. One or more of the lines displays its values using only markers These objects represent Fourier transform, 1/meanCycle, 1/Period.

참고 항목

|

관련 항목