在號令行窗口,輸入如下號令:
load sunspot.dat
year = sunspot(:,1);
relNums = sunspot(:,2);
plot(year,relNums)
title('Sunspot Data')
如圖1所示。
按“Enter鍵”,獲得Figure1。
如圖2所示。
以下是前50年的現狀。
在號令行窗口,輸入如下號令:
plot(year(1:50),relNums(1:50),'b.-');
如圖3所示。
旌旗燈號處置的根基東西是快速傅立葉變換(FFT)。要獲取太陽黑子數據的FFT,請鍵入以下內容。
Y的第一部門Y(1)只是數據的和,可以刪除。
在號令行窗口,輸入如下號令:
Y = fft(relNums);
Y(1) = [];
復平面上Fourier系數(由Y給出)的分布圖很標致,但很難詮釋。我們需要一種更有效的方式來查抄Y中的數據。
在號令行窗口,輸入如下號令:
plot(Y,'ro')
title('Fourier Coefficients in the Complex Plane');
xlabel('Real Axis');
ylabel('Imaginary Axis');
如圖4所示。
Y的復震級平方稱為功率,功率與頻率的關系圖稱為“周期圖”。
在號令行窗口,輸入如下號令:
n = length(Y);
power = abs(Y(1:floor(n/2))).^2;
nyquist = 1/2;
freq = (1:n/2)/(n/2)*nyquist;
plot(freq,power)
xlabel('cycles/year')
title('Periodogram')
如圖5所示。
周期/年的比例有些不便利。
我們可以用年/周期來作圖,估量一個周期的長度。
在號令行窗口,輸入如下號令:
plot(freq(1:40),power(1:40))
xlabel('cycles/year')
如圖6所示。
為了便利起見,我們繪制了功率與周期的關系圖(此中period=1./freq)。正如預期的那樣,有一個很是顯著的周期,其長度約為11年。
在號令行窗口,輸入如下號令:
period = 1./freq;
plot(period,power);
axis([0 40 0 2e+7]);
ylabel('Power');
xlabel('Period (Years/Cycle)');
如圖7所示。
最后,我們可以經由過程選擇最強的頻率來更切確地確定周期長度。紅點定位這一點。
在號令行窗口,輸入如下號令:
hold on;
index = find(power == max(power));
mainPeriodStr = num2str(period(index));
plot(period(index),power(index),'r.', 'MarkerSize',25);
text(period(index)+2,power(index),['Period = ',mainPeriodStr]);
hold off;
如圖8所示。
0 篇文章
如果覺得我的文章對您有用,請隨意打賞。你的支持將鼓勵我繼續創作!