📄 c10ex12.m
字号:
% This program utilizes the psd function to plot the % power spectral density of a cosine signal in Gaussian% noise for various combinations of FFT size and number of% segments averaged - Example 10-12%I_noise = input('Enter 1 for Gaussian noise of variance 5 added to signal ');N_tot = 2048;N_seg_0 = 8;k = 1:N_tot;f_0 = 20;del_t = 0.005;f_samp = 1/del_t;t = del_t*(k-1);max_t = max(t);x = cos(2*pi*f_0*(k-1)*del_t);n = sqrt(5)*randn(size(x));if I_noise == 1 x = x+n;else x = x;endsubplot(4,1,1),plot(t,x),axis([0 2 -5 5]),xlabel('t'),ylabel('x(t)')for l = 1:3N_seg = N_seg_0/2^(l-1);NFFT = N_tot/N_seg;[P, F] = PSD(x,NFFT,f_samp);subplot(4,1,l+1),plot(F,P),axis([0 100 -5 80]),ylabel('PSD - dB'),... text(40, 50, ['FFT points = ',num2str(NFFT),'; no. segments = ',num2str(N_seg)]) if l == 3 xlabel('frequency - Hz') endend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -