%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,'.');
The first time to exercise the convolution
最新推荐文章于 2022-09-13 01:31:35 发布