Digital signal processing (1)-spectrum analysis

Discrete Fourier Transform

Discrete Fourier Transform (DFT) is a discrete Fourier transform in both the time domain and the frequency domain, which transforms the sampling of the time domain signal into the frequency domain. In practical applications, Fast Fourier Transform ( FFT ) is usually used to efficiently calculate DFT.

The definition of DFT is:
Insert picture description here

Where N is the number of DFT points, the larger the number of points, the higher the frequency resolution, k=0,1,2,...,N-1.

Discrete Fourier transform can be regarded as a discrete time-domain signal and a discrete sine signal of different frequencies to perform correlation operations to obtain the amplitude (complex number) corresponding to the corresponding frequency.

MATLAB program

clc
clear
close all
 
 
N=2048;% ADC采样点数
Fs=1e6;% ADC采样率
t=(0:N-1)/Fs;% 采样时间序列
 
F1=60e3;% 信号频率1
F2=80e3;% 信号频率2
signal = cos(2*pi*F1 * t) + cos(2*pi*F2 * t);
 
figure;
plot(t,signal);
axis([0 inf -2.2 2.2]);
xlabel('时间/s');
title('时域信号');
 
% FFT
NN=2048;% NN点DFT
XN=fft(signal,NN)/NN;% 计算signal的NN点快速傅里叶变换
f0=Fs/NN;       % 频率分辨率
f=(0:NN-1)*f0;  % 频率序列
fk=(0:NN-1);    % 谱线序列
A=abs(XN);      % 幅值序列
Phase=atan(-real(XN)./imag(XN))/pi*180;  % 相位序列
 
figure;
subplot(2,1,1);
plot(f(1:NN/2),A(1:NN/2));
xlabel('频率/Hz');ylabel('幅度');
% axis([50e3 90e3 0 inf]);
title('FFT幅频谱');
subplot(2,1,2);
plot(f(1:NN/2),Phase(1:NN/2));
xlabel('频率/Hz');ylabel('相位/°');
title('FFT相频谱');
 
 
figure;
subplot(2,1,1);
plot(f(1:NN/2),real(XN(1:NN/2)));
xlabel('频率/Hz');
title('频谱实部');
subplot(2,1,2);
plot(f(1:NN/2),imag(XN(1:NN/2)));
xlabel('频率/Hz');
title('频谱虚部');

operation result

Insert picture description here

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/meng1506789/article/details/112898487