From octave-sources-request at bevo dot che dot wisc dot edu Fri Dec 13 10:27:56 2002 Subject: Function to generate convolution matrix From: Anand V To: octave-sources at bevo dot che dot wisc dot edu Date: Mon, 9 Dec 2002 08:03:52 -0600 Hi, I have written a function to generate the convolution matrix using the toeplitz function. I am appending it at the end. A convolution matrix is a matrix, formed from a vector, whose inner product with another vector is the convolution of the two vectors. A = convmtx(c,n) where c is a length m column vector returns a matrix A of size (m+n-1)-by-n. The product of A and another column vector x of length n is the convolution of c with x. A = convmtx(r,n) where r is a length m row vector returns a matrix A of size n-by-(m+n-1). The product of A and another row vector x of length n is the convolution of r with x. # Function to get convolution matrix given a vector 'h' and length of x (n) function retval = convmtx(h,n) if (nargin != 2) usage ("convmtx(h,n)"); endif nr = rows(h); nc = columns(h); if ( (nr > 1) && (nc > 1) ) usage("'h' should be either a row or column vector"); else if (nc == 1) h = h.'; endif r = [h,zeros(1,n-1)]; c = [1,zeros(1,n-1)]; endif if (nr == 1) retval = toeplitz(c,r); endif if (nc == 1) retval = toeplitz(c,r).'; endif endfunction _____________________________________________________________ Kerala's coolest community site ---> http://www.achayans.com India's fastest growing Search Engine -> http://www.indianindex.com India's largest Online Matchmakers --> http://www.indianalliance.com _____________________________________________________________ Select your own custom email address for FREE! Get you at yourchoice dot com w/No Ads, 6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag