《DSP using MATLAB》Problem 5.27

Posted ky027wh-sx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了《DSP using MATLAB》Problem 5.27相关的知识,希望对你有一定的参考价值。

技术分享图片

技术分享图片

代码:

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

‘);

banner();
%% +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

% -------------------------------------------------------------------
%                                               
% -------------------------------------------------------------------
N = 4;
n1 = [0:3];
x1 = [1, 3, 2, -1];


n2 = [0:3];
x2 = [2, 1, 0, -1];

% -----------------------------------
%     1st way to Linear-Convolution
% -----------------------------------
[y1, ny1] = conv_m(x1, n1, x2, n2);



% --------------------------------------------
%   2nd way ----  circular conv(FREQ domain)
% --------------------------------------------
N2 = length(x1)+length(x2)-1;
y2 = circonvf(x1, x2, N2);
ny2 = ny1;

% ---------------------------------------
%   3rd way --- Cir Conv (TIME domain)
% ---------------------------------------
N3 = length(x1)+length(x2)-1;
y3 = circonvt(x1, x2, N3);
ny3 = ny1;




N4 = 5;
y4 = circonvt(x1, x2, N4);
ny4 = [0:N4-1];


figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘P5.27 x1(n) and x2(n)‘)
set(gcf,‘Color‘,‘white‘); 
subplot(2,1,1); stem(n1, x1); 
xlabel(‘n‘); ylabel(‘x1(n)‘);
title(‘x1(n), N=4‘);  grid on;
subplot(2,1,2); stem(n2, x2);  
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘n‘); ylabel(‘x2(n)‘);
title(‘x2(n), N=4‘);  grid on;



figure(‘NumberTitle‘, ‘off‘, ‘Name‘, ‘P5.27 Convolution‘)
set(gcf,‘Color‘,‘white‘); 
subplot(2,2,1); stem(ny1, y1); 
xlabel(‘n‘); ylabel(‘y1(n)‘);
title(‘Linear-Conv y1(n), N=7‘);  grid on;
subplot(2,2,2); stem(ny2, y2);  
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘n‘); ylabel(‘y2(n)‘);
title(‘Cir-Conv(FREQ domain) y2(n), N=7‘);  grid on;
subplot(2,2,3); stem(ny3, y3);  
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘n‘); ylabel(‘y3(n)‘);
title(‘Cir-Conv(TIME domain) y3(n), N=7‘);  grid on;
subplot(2,2,4); stem(ny4, y4);  
%axis([-N/2, N/2, -0.5, 50.5]);
xlabel(‘n‘); ylabel(‘y4(n)‘);
title(‘Cir-Conv(TIME domain) y4(n), N=5‘);  grid on;

  运行结果:

技术分享图片

技术分享图片

技术分享图片

        上图中,y1是长度为7的线性卷积结果,y4是5点圆周卷积结果。

 

以上是关于《DSP using MATLAB》Problem 5.27的主要内容,如果未能解决你的问题,请参考以下文章

《DSP using MATLAB》Problem 5.7

《DSP using MATLAB》Problem 6.7

《DSP using MATLAB》Problem 6.8

《DSP using MATLAB》Problem 3.12

《DSP using MATLAB》Problem 4.17

《DSP using MATLAB》Problem 3.5