代码:
%% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf(' *********************************************************** '); fprintf(' <DSP using MATLAB> Problem 5.23 '); banner(); %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ % ------------------------------------------------------------------- % % % ------------------------------------------------------------------- n = [0:6]; x = [1, 2, -3, 4, -5, 0, 0]; N = 7; x_cir_fold = x(mod(-n, N)+1); m = -1; y = cirshftt(x_cir_fold, m, 7); ny = [0:6]; figure('NumberTitle', 'off', 'Name', 'P5.23 x(n) x((-n)) x((-8-n))') set(gcf,'Color','white'); subplot(3,1,1); stem(n, x); xlabel('n'); ylabel('x'); title('x(n), N=7'); grid on; subplot(3,1,2); stem(n, x_cir_fold); xlabel('n'); ylabel(''); title('x((-n)), N=7'); grid on; subplot(3,1,3); stem(ny, y); xlabel('n'); ylabel('y'); title('x((-8-n)), N=7'); grid on;
运行结果: