不同信噪比下20MHz正弦信号的FFT频谱分析及作图
Matlab代码:
%% FFT Analysis of f=20MHz sinusoid with different SNR
clc;
clear all;
close all;
fs=50e6; %sampling frequency
t=0:1/fs:0.01; %time vector
f1=20e6; %signal frequency
for SNR=-20:-10:0 %generate different SNR
%%Generate sinusoid with given SNR
x=sin(2pif1*t); %sinusoidal signal
sigma_x=(max(x)-min(x))/sqrt(2); %standard deviation of signal
sigma_n=(sigma_x/(10^(SNR/10))); %standard deviation of noise based on given SNR
n = sigma_n.*randn(size(t)); %noise vector
y = x + n; %received signal (signal + noise)
%%FFT Analysis
Nfft=1024; %length of FFT points
Y = fftshift(fft((y),Nfft)); %do FFT and shift the result
Pyy = Y.conj(Y)/Nfft; %power spectrum from 0 to fs/2 (normalized) freq=(-Nfft/2:(Nfft/2)-1)fs/Nfft ; subplot (3, 1, -SNR/-10+3 ); plot (freq,Pyy); hold on ; grid on ; title ([ 'FFT Analysis for ' num2str(-SNR) ' dB' ] ); xlabel ('Frequency [Hz]'); ylabel ('Power Spectral Density [V^2 / Hz]'); end
Prev:社团招生口号