《DSP using MATLAB》Problem 5.35
余弦序列的谱,原始频率w0会泄露到其它频率处。
从其它书中找到的证明过程:
代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 5.35 \n\n'); banner(); %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ------------------------------------------------------------------------------------- % X(k) is DFTs of real-valued sequence x(n) % x(n)=A*cos(wn)R(n) n=[0:N-1] % % x(n) = cos(5*pi*n/99) n=[0:200-1] % ------------------------------------------------------------------------------------- N = 200; A = 1; n1 = [0:N-1]; x1 = A*cos(5*pi*n1/99); figure('NumberTitle', 'off', 'Name', 'P5.35 x(n), N=200') set(gcf,'Color','white'); stem(n1, x1); xlabel('n'); ylabel('x(n)'); title('x(n)=cos(5\pin/99)'); grid on; k1 = [0:N-1]; Xk_DFT = fft(x1, N); N1 = length(Xk_DFT); % length magXk_DFT = abs( [ Xk_DFT ] ); % DFT magnitude angXk_DFT = angle( [Xk_DFT] )/pi; % DFT angle realXk_DFT = real(Xk_DFT); imagXk_DFT = imag(Xk_DFT); figure('NumberTitle', 'off', 'Name', 'P5.35 X(k), N=200') set(gcf,'Color','white'); subplot(2,1,1); stem(k1, realXk_DFT); xlabel('k'); ylabel('real (k)'); title('real DFT of x(n)'); grid on; subplot(2,1,2); stem(k1, imagXk_DFT); %axis([-N/2, N/2, -0.5, 50.5]); xlabel('k'); ylabel('imag (k)'); title('imag DFT of x(n)'); grid on;
运行结果:
牢记:
1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。