(New page: % 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...) |
|||
Line 1: | Line 1: | ||
+ | |||
+ | <nowiki> | ||
% Adam Siembida | % Adam Siembida | ||
% ECE 301 - HW2 - P7 | % ECE 301 - HW2 - P7 | ||
Line 29: | Line 31: | ||
fprintf('%i ',y); | fprintf('%i ',y); | ||
fprintf(']\n'); | fprintf(']\n'); | ||
+ | |||
+ | </nowiki> |
Revision as of 18:55, 1 July 2009
% 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');