% Adam Siembida % ECE 301 - HW2 - P7 % initialize workspace clear all; format compact; clc; % x and h are vectors to be convolved. y is x*h x = input('Input vector x in the format [a b c ...]: '); h = input('Input vector h in the format [a b c ...]: '); ylen = length(x)+length(h)-1; y = zeros(1,ylen); %hr is h reversed in order hr = h(end:-1:1); % pad x and hr with zeros to make my algorithm work x=[zeros(1,ylen-length(x)) x]; hr=[hr zeros(1,ylen-length(hr))]; for i=1:ylen y(i) = dot(x, hr); hr = hr([end 1:end-1]); end fprintf('\n'); fprintf('x*h = [ '); fprintf('%i ',y); fprintf(']\n');