www.gusucode.com > signal 案例源码程序 matlab代码 > signal/SignaltoNoiseRatioOfASinusoidExample.m
%% Signal-to-Noise Ratio of Sinusoid % Compute the SNR of a 2.5 kHz sinusoid sampled at 48 kHz. Add white noise % with variance 0.001². %% Fi = 2500; Fs = 48e3; N = 1024; x = sin(2*pi*Fi/Fs*(1:N)) + 0.001*randn(1,N); SNR = snr(x,Fs) %% % Plot the spectrum and annotate the SNR. snr(x,Fs);