?? exmp2_11.m
字號(hào):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% exmp2_11.m - Waveform and spectrum of sinewave corrupted by
% white noise with Signal-to-noise ratio = 10 dB
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N=256; A=sqrt(20); w0=0.2*pi; % define parameters
n = [0:N-1]; % time index
sn = A*sin(w0*n); % sine sequence
vn = (rand(1,N)-0.5)*sqrt(12); % zero-mean, unit-variance white noise
xn = sn+vn; % sinewave embedded in white noise
subplot(2,1,1); % top figure
plot(n,xn) % plot the waveform
title('Waveform of noisy sinewave');
xlabel('Time index n'); ylabel('Amplitude');
axis([0 255 -inf inf])
Xk = fft(xn); % compute DFT
absXk = 20*log10(abs(Xk)); % magnitude spectrum in dB
subplot(2,1,2); % bottom figure
plot(n,absXk) % plot the spectrum
title('Spectrum of noisy sinewave');
xlabel('Frequency index k'); ylabel('Magnitude in dB');
axis([0 127 -inf inf])
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -