From octave-sources-request at bevo dot che dot wisc dot edu Mon Dec 16 09:42:46 2002 Subject: Convolution matrix function(debugged) From: Anand V To: octave-sources at bevo dot che dot wisc dot edu Date: Sun, 15 Dec 2002 22:33:39 -0600 Hi, I had to modify the function as I found a bug during testing. It is because of the toeplitz matrix function call. If the first element,of the row and column are different, then the column will win the diagonal conflict in Toeplitz matrix. I have corrected this and am appending the new code. I have tested it for programs where I needed to generate convolution matrix and operate. It seems to give satisfactory results. # 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"); elseif (nc == 1) h = h.'; endif r = [h,zeros(1,n-1)]; c = [h(1),zeros(1,n-1)]; if (nr == 1) retval = toeplitz(c,r); endif if (nc == 1) retval = toeplitz(c,r).'; endif endfunction Thanks and Regards Anand _____________________________________________________________ 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