- 积分
- 16247
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2014-4-17
- 最后登录
- 1970-1-1
|
发表于 2019-11-13 09:11:18
|
显示全部楼层
% This is for power spectrum analysis.
clear;
load QR_jp0302;
for i=1:12:1200
jpn(i)=sum(QR_jp0302(i:i+11))/12;
% jpn(i)=yjp(i);
end
for j=1:100
x(j)=jpn(12*(j-1)+1);
end
y = fft(x); %Fourier transform, default length = N
N = length(y);
y(1) = [];
power = abs(y(1:N/2)).^2;
nyquist = 1/2;
freq = (1:N/2)/(N/2)*nyquist;
period = 1./freq;
[mp,index] = max(power);
period(index);
[pxx,k]=psd(x,100,100,hanning(100),50,0.95,'none');
pxxgj=pxx.*((7.815+9.488)/2/3.5); psum=0;
%pxxgj=pxx.*((6.251+7.779)/2/3.5); psum=0; % alfa=0.10, r=3.5 freedum,
for i=1:length(pxx);psum=psum+pxxgj(i);end;
pxxc=psum/length(pxx); % 5% of Avg. PS line!
%[pzq,f] = periodogram(x,hanning(50),50,50-1);
subplot('position',[0.1 0.73 0.65 0.25])
plot(period,power,'r'),%axis([0 20 0 2e2])
xlabel('Period(/Years)')
ylabel('Power')
%title('Periodogram')
subplot('position',[0.1 0.40 0.65 0.25])%Plot Periodgram
plot(freq,power,'b') % ,grid on
%plot([0 freq],pzq,'b') % ,grid on
ylabel('Power')
xlabel('frequence')
hold on
%plot(freq,0.05*sum(power),'k-.')
hold off
%Plot PSDgram
subplot('position',[0.1 0.07 0.65 0.25])
plot(k,pxx,'m')%,axis([0 25 0 1]) % ,grid on
ylabel('Power Spectrum')
xlabel('Wave Number')
hold on
plot(xlim,pxxc+[0,0],'k:')
%plot(k,pxx(index+1)/(index+1),'r--')
hold off |
|