The first time to exercise the convolution

%Coder writer : The.L
%Date: 11.04.2013

%Declaration
%-------------------------------------------------------------------------------
%My email:liuzijianlinux@gmail.com   
%If something could be done
%better,touch me by the email adress.I would glad to communicate with you
%and talk about the digital signal and process

%-------------------------------------------------------------------------------


%%  The first time to exercise the convolution

%% initialize the varible in this programe
x = zeros(9,1); % the input signal sequence
h = zeros(4,1); % the impulse response 
y = zeros(12,1);% the output signal sequence

%% the original data in the matrix X and H
%-----------------------------------------------------------------
x(1) = 0;
x(2) = -1;
x(3) = -1.2;
x(4) = 2;
x(5) = 1.4;
x(6) = 1.4;
x(7) = 0.8;
x(8) = 0;
x(9) = -0.8;
h(1) = 1;
h(2) = -0.6;
h(3) = -0.4;
h(4) = -0.1;
%-----------------------------------------------------------------
%% figure out the original signal and impulse response 
figure(1);
subplot(211);
plot(x,'.');
subplot(212);
plot(h,'.');

%% the convolution process(wait for changing into a good expression)
for temp = 1:9
    if temp == 1
        y(temp) = x(temp)*h(1);
    elseif temp == 2
             y(temp) = x(temp)*h(1)+x(temp-1)*h(2);
    elseif temp == 3
                y(temp) = x(temp)*h(1)+x(temp-1)*h(2)+x(temp-2)*h(3); 
    elseif temp >= 4
                y(temp) = x(temp)*h(1)+x(temp-1)*h(2)+x(temp-2)*h(3)+x(temp-3)*h(4);       
    end
end

%% figure out the output signals
figure(2);
plot(y,'.');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值