📄 example8_5.m
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% example8_5.m - Program for power spectrum estimation
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all, close all;
t=0:0.001:3; % 3 secs @ 1kHz sample rate
x = chirp(t,0,1,100); % chirp signal sweeps linearly
N = 1024;Fs = 1000 % using 1024-point FFT and Fs = 1000Hz
pse = abs(fft(x,N)).^2/N;
pse_dB = 10*log10(pse); % power Spectrum in dB
figure; plot(0:1000/N:500,pse_dB(1:513)),
title('Power Spectrum Estimation of x');
xlabel('Frequency axis(Hz)');
ylabel('Power (dB)');
% An alternate way to compute PSE in MATLAB
figure;
PSD(x,N,Fs);
title('Welch Periodogram of x');
% Using specgram to plot the spectrogram of the chirp signal
figure;
specgram(x,[],Fs);colorbar;
title('Spectrogram of x');
% Use this section to illustrate the time-freq tradeoff
figure;
subplot(311), specgram(x,256,Fs); title('Spectrogram using 256 point');
subplot(312), specgram(x,512,Fs); title('Spectrogram using 512 point');
subplot(313), specgram(x,1024,Fs); title('Spectrogram using 1204 point');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -