《DSP using MATLAB》Problem 2.15

代码:

%% ------------------------------------------------------------------------
%%            Output Info about this m-file
fprintf(‘\n***********************************************************\n‘);
fprintf(‘        <DSP using MATLAB> Problem 2.15 \n\n‘);

banner();
%% ------------------------------------------------------------------------

nx1 = [-3:3]; x1 = [2, -4, 5, 3, -1, -2, 6];
nh1 = [-1:3]; h1 = [1, -1, 1, -1, 1];

nx2 = [-2:2]; x2 = [1, 1, 0, 1, 1];
nh2 = [-3:0]; h2 = [1, -2, -3, 4];

nx3 = [-2:6]; x3 = (0.25 .^ (-nx3)) .* (stepseq(-1, -2, 6) - stepseq(4, -2, 6));
nh3 = [-2:6]; h3 = stepseq(0, -2, 6) - stepseq(5, -2, 6);

nx4 = [-3:7]; x4 = (nx4/4) .* (stepseq(0, -3, 7) - stepseq(6, -3, 7)) ;
nh4 = [-3:7]; h4 = 2 * (stepseq(-2, -3, 7) - stepseq(3, -3, 7));

[y1, ny1] = conv_m(x1, nx1, h1, nh1);
[y2, ny2] = conv_m(x2, nx2, h2, nh2);
[y3, ny3] = conv_m(x3, nx3, h3, nh3);
[y4, ny4] = conv_m(x4, nx4, h4, nh4);

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.15‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色

subplot(3,1,1); stem(nx1, x1); title(‘x1 sequence‘);
xlabel(‘n‘); ylabel(‘x(n)‘) ;
grid on
subplot(3,1,2); stem(nh1, h1); title(‘h1 sequence‘);
xlabel(‘n‘); ylabel(‘h1(n)‘);
grid on;
subplot(3,1,3); stem(ny1, y1); title(‘y1=x1*h1 sequence‘);
xlabel(‘n‘); ylabel(‘y1(n)‘);
grid on;

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.15‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色

subplot(3,1,1); stem(nx2, x2); title(‘x2 sequence‘);
xlabel(‘n‘); ylabel(‘x2(n)‘) ;
grid on
subplot(3,1,2); stem(nh2, h2); title(‘h2 sequence‘);
xlabel(‘n‘); ylabel(‘h2(n)‘);
grid on;
subplot(3,1,3); stem(ny2, y2); title(‘y2=x2*h2 sequence‘);
xlabel(‘n‘); ylabel(‘y2(n)‘);
grid on;

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.15‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色

subplot(3,1,1); stem(nx3, x3); title(‘x3 sequence‘);
xlabel(‘n‘); ylabel(‘x3(n)‘) ;
grid on
subplot(3,1,2); stem(nh3, h3); title(‘h3 sequence‘);
xlabel(‘n‘); ylabel(‘h3(n)‘);
grid on;
subplot(3,1,3); stem(ny3, y3); title(‘y3=x3*h3 sequence‘);
xlabel(‘n‘); ylabel(‘y3(n)‘);
grid on;

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.15‘)
set(gcf,‘Color‘,[1,1,1])                  % 改变坐标外围背景颜色

subplot(3,1,1); stem(nx4, x4); title(‘x4 sequence‘);
xlabel(‘n‘); ylabel(‘x4(n)‘) ;
grid on
subplot(3,1,2); stem(nh4, h4); title(‘h4 sequence‘);
xlabel(‘n‘); ylabel(‘h4(n)‘);
grid on;
subplot(3,1,3); stem(ny4, y4); title(‘y4=x4*h4 sequence‘);
xlabel(‘n‘); ylabel(‘y4(n)‘);
grid on;

  运行结果:

时间: 2024-10-11 14:14:52

《DSP using MATLAB》Problem 2.15的相关文章

《DSP using MATLAB》Problem 6.15

代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 6.15 \n\n'); ba

《DSP using MATLAB》Problem 7.15

用Kaiser窗方法设计一个台阶状滤波器. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> P

《DSP using MATLAB》Problem 8.15

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 8.15 \n\n'); banner();

《DSP using MATLAB》Problem 3.4

代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 3.4 \n\n'); banner(); %

《DSP using MATLAB》Problem 3.9

利用的频移性质为: 本习题代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 3.9 \n\n')

《DSP using MATLAB》Problem 5.11

代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 5.11 \n\n'); ba

《DSP using MATLAB》Problem 5.13

1. 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 5.13 \n\n');

《DSP using MATLAB》Problem 5.14

说明:这两个小题的数学证明过程都不会,欢迎博友赐教. 直接上代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MA

《DSP using MATLAB》Problem 5.21

证明: 代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 5.2