From help-octave-request at bevo dot che dot wisc dot edu Thu Dec 6 18:06:00 2001 Subject: Re: using conv vs. filter From: "Stephen W. Juranich" To: "E. Joshua Rigler" Cc: Help-Octave Date: Thu, 6 Dec 2001 18:05:02 -0600 > I'm looking at the code for conv.m in the octave libraries. It does > some sort of zero-padding, then calls the "filter" function. The output > is a vector that is length(a)+lenght)b)+1. If you're using digital filtering techniques, then convolving two signals (call them 'a' and 'b'), then the length of the result of the convolution is going to be length(a)+length(b)-1 (not +1). The only reason this will not be true is if you're sampling below the Nyquist rate, at which point you have aliasing (generally considered a Bad Thing [tm]). > Now, I am trying to convolve an filter with both negative, zero, and > positively lagged coefficients with an input time series. In order for > my time-steps to be synchronized between the input time series, and the > output from conv.m, how would I index the output? I guess I just don't > really understand how the conv.m function works in octave. I assume you're talking about a non-causal filter. Let's say that your first non-zero coefficient in the filter is a[-k] and the input signal starts at b[0]. Then the filter is going to look k samples into the future and start convolving there. So you will start getting output at time = -k. > At the moment, I use a filter that has an equal number of positive and > negatively lagged coefficients, and the output seems reasonable when I > do something like: > > output = conv (filter, input); > output = output (length(filter)/2 : length(output)- \ > length(filter)/2); > > 1) Does what I have seem right? > 2) What do I do if my filter has fewer/more negatively lagged > coefficients than positively lagged coefficients? As I mentioned before you _expect_ the result to be longer than the two inputs, so unless you *really* know what you're doing (and you'd have to be doing something really funky), you should keep them all. Having said all that, It's been a couple of years since my last linear systems class, so some of the details might have been clouded up in my mind (especially that stuff in the second paragraph). :) HTH -------------------------------------------------------------------------- Stephen W. Juranich sjuranic at ee dot washington dot edu Electrical Engineering http://students.washington.edu/sjuranic University of Washington http://ssli.ee.washington.edu/ssli ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------