help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using conv vs. filter


From: E. Joshua Rigler
Subject: Re: using conv vs. filter
Date: 06 Dec 2001 09:33:16 -0700

Thanks Paul!  You were the only one (of those who responded) who
actually understood my question.  I'm sure that was my own fault for not
stating it very clearly.  I thought others might benefit from your
answer.  At the very least, this should go into the new search-able
archive (yea!), so people like me don't have to waste bandwidth with
questions like this in the future.

-EJR


On Thu, 2001-12-06 at 08:48, Paul Kienzle wrote:
> For the output y=conv(b,x), you need to extract y([1:length(x)]+L), where L
> is the maximum lag of your filter.  The following example should clarify:
> 
>  ## generate some data
>  t = linspace(0,1,100);
>  x = sin(2*pi*t*2.4+0.2) + randn(size(t))*0.3;    
> 
>  ## generate causal (c) and non-causal (nc) filters
>  F = sgolay(3,15);                                
>  c = F(15,:); % lags 14, 13, ..., 1, 0
>  nc = F(1,:); % lags 0, -1, ..., -14
> 
>  ## filter the data using conv
>  y_c = conv(c,x); 
>  y_c = y_c([1:length(t)]+14);
>  y_nc = conv(nc,x); 
>  y_nc = y_nc([1:length(t)]+0);
> 
>  ## plot the filters and the results
>  subplot(211); plot(c,';causal;',nc,';non-causal;');
>  subplot(212); plot(t,y_c,';causal;', t,y_nc,';non-causal;',t,x,';data;');
> 
> Paul Kienzle
> address@hidden
> 
> 
> On Wed, Dec 05, 2001 at 01:29:09PM -0700, E. Joshua Rigler wrote:
> > 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.
> > 
> > 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.
> > 
> > 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?
> > 
> > Thanks,
> > 
> > -EJR
> > 
> > 
> > 
> > -------------------------------------------------------------
> > 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
> > -------------------------------------------------------------
> > 




-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]