《DSP using MATLAB》示例Example5.5
代码:
%% ---------------------------------------------------------- %% START N=5 %% ---------------------------------------------------------- N = 5; k = 0:1:N-1; % sample index wk = 2*pi*k/N; zk = exp(j*wk); % samples of z Xk = (zk)./(zk-0.7); % DFS as samples of X(z) xn = real(idfs(Xk,N)); % IDFS xtilde = xn'*ones(1,8); xtilde = (xtilde(:))'; % Periodic sequence figure('NumberTitle', 'off', 'Name', 'Example5.5') set(gcf,'Color','white'); subplot(2,2,1); stem(0:39, xtilde); axis([0, 40, -0.1, 1.5]); xlabel('n'); ylabel('xtilde(n)'); grid on; title('N=5'); %% ----------------------------------------------------------- %% END N=5 %% ----------------------------------------------------------- %% ---------------------------------------------------------- %% START N=10 %% ---------------------------------------------------------- N = 10; k = 0:1:N-1; % sample index wk = 2*pi*k/N; zk = exp(j*wk); % samples of z Xk = (zk)./(zk-0.7); % DFS as samples of X(z) xn = real(idfs(Xk,N)); % IDFS xtilde = xn'*ones(1,4); xtilde = (xtilde(:))'; % Periodic sequence subplot(2,2,2); stem(0:39, xtilde); axis([0, 40, -0.1, 1.5]); xlabel('n'); ylabel('xtilde(n)'); grid on; title('N=10'); %% ---------------------------------------------------------- %% END N=10 %% ---------------------------------------------------------- %% ---------------------------------------------------------- %% START N=20 %% ---------------------------------------------------------- N = 20; k = 0:1:N-1; % sample index wk = 2*pi*k/N; zk = exp(j*wk); % samples of z Xk = (zk)./(zk-0.7); % DFS as samples of X(z) xn = real(idfs(Xk,N)); % IDFS xtilde = xn'*ones(1,2); xtilde = (xtilde(:))'; % Periodic sequence subplot(2,2,3); stem(0:39, xtilde); axis([0, 40, -0.1, 1.5]); xlabel('n'); ylabel('xtilde(n)'); grid on; title('N=20'); %% ---------------------------------------------------------- %% END N=20 %% ---------------------------------------------------------- %% ---------------------------------------------------------- %% START N=40 %% ---------------------------------------------------------- N = 40; k = 0:1:N-1; % sample index wk = 2*pi*k/N; zk = exp(j*wk); % samples of z Xk = (zk)./(zk-0.7); % DFS as samples of X(z) xn = real(idfs(Xk,N)); % IDFS xtilde = xn'*ones(1,1); xtilde = (xtilde(:))'; % Periodic sequence subplot(2,2,4); stem(0:39, xtilde); axis([0, 40, -0.1, 1.5]); xlabel('n'); ylabel('xtilde(n)'); grid on; title('N=40'); %% ---------------------------------------------------------- %% END N=40 %% ----------------------------------------------------------
运行结果:
牢记:
1、如果你决定做某事,那就动手去做;不要受任何人、任何事的干扰。2、这个世界并不完美,但依然值得我们去为之奋斗。