代码:
n = 0:10; x = 10*(0.8) .^ n; y = x(mod_1(-n,11)+1); %% ----------------------------------------------------------------- %% START a %% ----------------------------------------------------------------- figure('NumberTitle', 'off', 'Name', 'Exameple5.9a x sequence') set(gcf,'Color','white'); subplot(2,1,1); stem(n,x); title('Original sequence x(n)'); %axis([0,10,-2.5,2.5]); xlabel('n'); ylabel('x(n)'); grid on; subplot(2,1,2); stem(n,y); title('Circularly folded sequence y(n)'); %axis([0,10,-2.5,2.5]); xlabel('n'); ylabel('y(n)=x(-n mod 10)'); grid on; %% ----------------------------------------------------------------- %% END a %% ----------------------------------------------------------------- %% ----------------------------------------------------------------- %% START b %% ----------------------------------------------------------------- X_DFT = dft(x,11); Y_DFT = dft(y,11); % DFT of x and y realX_DFT = real(X_DFT); imagX_DFT = imag(X_DFT); realY_DFT = real(Y_DFT); imagY_DFT = imag(Y_DFT); figure('NumberTitle', 'off', 'Name', 'Exameple5.9b x sequence') set(gcf,'Color','white'); subplot(2,2,1); stem(n,realX_DFT); title('Real {DFT[x(n)]}'); %axis([0,N,-0.5,1.5]); xlabel('k'); grid on; subplot(2,2,2); stem(n,imagX_DFT); title('Imag {DFT[x(n)]}'); %axis([0,N,-0.5,1.5]); xlabel('k'); grid on; subplot(2,2,3); stem(n,realY_DFT); title('Real {DFT[x((-n))11]}'); %axis([0,N,-0.5,1.5]); xlabel('k'); grid on; subplot(2,2,4); stem(n,imagY_DFT); title('Imag {DFT[x((-n))11]}'); %axis([0,N,-0.5,1.5]); xlabel('k'); grid on; %% ----------------------------------------------------------------- %% END b %% -----------------------------------------------------------------
运行结果: