example8_5.m

来自「用dsp解压mp3程序的算法」· M 代码 · 共 35 行

M
35
字号
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 + =
减小字号Ctrl + -
显示快捷键?