《DSP using MATLAB》Problem 2.16

先由脉冲响应序列h(n)得到差分方程系数,过程如下:

代码:

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

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

%% ------------------------------------------------------
%%              sequence of 51 samples
%% ------------------------------------------------------
nx1 = [-1:49]; x1 = (0.8 .^ nx1) .* stepseq(0, -1, 49);
nh1 = [-1:49]; h1 = ( (-0.9).^nh1 ) .* stepseq(0, -1, 49);

[y1, ny1] = conv_m(x1, nx1, h1, nh1);

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.16‘)
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;

%% -----------------------------------------------------
%%         Trancate to 26 samples
%% -----------------------------------------------------
nx2 = [-1:24]; x2 = (0.8 .^ nx2) .* stepseq(0, -1, 24);
nh2 = [-1:24]; h2 = ( (-0.9).^nh2 ) .* stepseq(0, -1, 24);

[y2, ny2] = conv_m(x2, nx2, h2, nh2);

figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘Problem 2.16‘)
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;

%% ----------------------------------------------------------
%%            filter function
%% ----------------------------------------------------------
b = [1]; a = [1, 0.9];

y3 = filter(b, a, x1);

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

%subplot(3,1,3);
stem(nx1, y3); title(‘y3 sequence‘);
xlabel(‘n‘); ylabel(‘y3(n)‘);
grid on;

  运行结果:

时间: 2024-10-03 15:48:20

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

《DSP using MATLAB》Problem 4.11

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

《DSP using MATLAB》Problem 7.36

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

《DSP using MATLAB》Problem 8.31

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

《DSP using MATLAB》 Problem 2.3

本题主要是显示周期序列的. 1.代码: %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.3.1 \

《DSP using MATLAB》Problem 2.5

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

《DSP using MATLAB》Problem 2.6

1.代码 %% ------------------------------------------------------------------------ %% Output Info about this m-file fprintf('\n***********************************************************\n'); fprintf(' <DSP using MATLAB> Problem 2.6.1 \n\n'); [v, d] =

《DSP using MATLAB》Problem 2.8

1.代码: 从MATLAB官方网上下载的. %*************************************************************************% %A code for the Downsampler% %Author: Yashwant Marathe% %Date:20-12-2010% function [y ny] = dnsample(x,n,M) %x is a sequence over indices specified by v

《DSP using MATLAB》Problem 2.14

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

《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();