DSPRelated.com
Forums

Circular convolution

Started by arsalan April 24, 2011
I want to write a Matlab code to convolve the two signals: x=[1 2 3
4]; y=[1 -1 3].
I want to do it through circular convolution. Please kindly any body
could help in guiding how to generate the code which should be in
generic form that could be used for all signals. Thank you
>I want to write a Matlab code to convolve the two signals: x=[1 2 3 >4]; y=[1 -1 3]. >I want to do it through circular convolution. Please kindly any body >could help in guiding how to generate the code which should be in >generic form that could be used for all signals. Thank you >
Look for "cconv" help in matlab. That will guide you through. Dhaval
On Apr 24, 2:07&#4294967295;pm, arsalan <ardkhan...@yahoo.com> wrote:
> I want to write a Matlab code to convolve the two signals: x=[1 2 3 > 4]; y=[1 -1 3]. > I want to do it through circular convolution. Please kindly any body > could help in guiding how to generate the code which should be in > generic form that could be used for all signals. Thank you
It is likly most instructive to actually do this by hand and then work on programming Matlab to get a similar result.
On Apr 25, 9:51&#4294967295;am, Clay <c...@claysturner.com> wrote:
> On Apr 24, 2:07&#4294967295;pm, arsalan <ardkhan...@yahoo.com> wrote: > > > I want to write a Matlab code to convolve the two signals: x=[1 2 3 > > 4]; y=[1 -1 3]. > > I want to do it through circular convolution. Please kindly any body > > could help in guiding how to generate the code which should be in > > generic form that could be used for all signals. Thank you > > It is likly most instructive to actually do this by hand and then work > on programming Matlab to get a similar result.
To do that, arsalan would need to understand what circular convolution is. That might be too much like actually *doing* the homework. Jerry -- Engineering is the art of making what you want from things you can get.
On Apr 25, 9:10&#4294967295;am, Jerry Avins <j...@ieee.org> wrote:

> > To do that, arsalan would need to understand what circular convolution > is. That might be too much like actually *doing* the homework. >
Not to do Arsalan's homework for him (her?), but how do comp.dsp-ers define the circular convolution of two sequences of different lengths (which is what Arsalan has in his question: lengths 4 and 3)? (a) zero-pad the shorter sequence to have the same length as the longer one? (b) zero-pad both to length equal to the sum of the lengths (or the sum minus one for nitpickers)? (c) periodically extend both to length equal to the least common multiple of the lengths? (d)? Another question that springs to mind is "If linear convolution is desired, why should circular convolution be used at all unless the intent is to use the FFT algorithm to speed up the calculations?" Absent the use of the FFT algorithm, using DFTs to compute a circular convolution in order to get a linear convolution result seems to be similar to scratching your left ear with your right hand after wrapping your arm twice around your head. Heck of a way to get rid of an itch! --Dilip Sarwate
On Apr 25, 4:49&#4294967295;pm, dvsarwate <dvsarw...@yahoo.com> wrote:
> On Apr 25, 9:10&#4294967295;am, Jerry Avins <j...@ieee.org> wrote: > > > > > To do that, arsalan would need to understand what circular convolution > > is. That might be too much like actually *doing* the homework. > > Not to do Arsalan's homework for him (her?), but > how do comp.dsp-ers define the circular convolution > of two sequences of different lengths (which is > what Arsalan has in his question: lengths 4 and 3)? > > (a) zero-pad the shorter sequence to have the > same length as the longer one? > > (b) zero-pad both to length equal to the sum of > the lengths (or the sum minus one for nitpickers)? > > (c) periodically extend both to length equal to > the least common multiple of the lengths? > > (d)? > > Another question that springs to mind is > "If linear convolution is desired, why should > circular convolution be used at all unless the > intent is to use &#4294967295;the FFT algorithm to speed > up the calculations?" &#4294967295;Absent the use of the > FFT algorithm, using DFTs to compute a > circular convolution in order to get a linear > convolution result seems to be similar to > scratching your left ear with your right hand > after wrapping your arm twice around your > head. &#4294967295;Heck of a way to get rid of an itch! > > --Dilip Sarwate
That's why I suggested doing it by hand first. It would immediately get (I hope) the OP to raise some questions. Clay
On 4/25/2011 1:49 PM, dvsarwate wrote:
> On Apr 25, 9:10 am, Jerry Avins<j...@ieee.org> wrote: > >> >> To do that, arsalan would need to understand what circular convolution >> is. That might be too much like actually *doing* the homework. >> > > > Not to do Arsalan's homework for him (her?), but > how do comp.dsp-ers define the circular convolution > of two sequences of different lengths (which is > what Arsalan has in his question: lengths 4 and 3)? > > (a) zero-pad the shorter sequence to have the > same length as the longer one? > > (b) zero-pad both to length equal to the sum of > the lengths (or the sum minus one for nitpickers)? > > (c) periodically extend both to length equal to > the least common multiple of the lengths? > > (d)? > > Another question that springs to mind is > "If linear convolution is desired, why should > circular convolution be used at all unless the > intent is to use the FFT algorithm to speed > up the calculations?" Absent the use of the > FFT algorithm, using DFTs to compute a > circular convolution in order to get a linear > convolution result seems to be similar to > scratching your left ear with your right hand > after wrapping your arm twice around your > head. Heck of a way to get rid of an itch! > > --Dilip Sarwate >
Dilip, Indeed a heck of a way! But "compute a circular convolution in order to get a linear convolution result [of finite sequences]" is, or should almost always be, the objective. That is, I don't imagine circular convolution results that are different than the linear convolution results - unless one of the sequences is rather arbitrarily truncated in order to be treated as finite. Even in that case, multiple results can be combined to yield the "continuous" result. So we agree that it *must* be to get speedup to be sensible and, by the way, it's possible to get even greater speedup by performing some tricks in frequency (as used in interpolation). Fred
On Apr 25, 5:38&#4294967295;pm, Fred Marshall <fmarshallxremove_th...@acm.org>
wrote:

  ...

> So we agree that it *must* be to get speedup to be sensible and, by the > way, it's possible to get even greater speedup by performing some tricks > in frequency (as used in interpolation).
I don't agree. Occam's razor suggests that circular convolution is merely the way the problem was assigned. Jerry -- Engineering is the art of making what you want from things you can get.
On Apr 25, 10:49&#4294967295;pm, dvsarwate <dvsarw...@yahoo.com> wrote:
> On Apr 25, 9:10&#4294967295;am, Jerry Avins <j...@ieee.org> wrote: > > > > > To do that, arsalan would need to understand what circular convolution > > is. That might be too much like actually *doing* the homework. > > Not to do Arsalan's homework for him (her?), but > how do comp.dsp-ers define the circular convolution > of two sequences of different lengths (which is > what Arsalan has in his question: lengths 4 and 3)?
As always, I choose the more controversial approach: As far as I am concerned, circular convolution is an unwanted side effect that appears if / when one implements the 'usual' convolution by the DFT / FFT. I am not aware of any applications where the circular convolution is desired. Rune
On Apr 25, 2:13&#4294967295;pm, Clay <c...@claysturner.com> wrote:
> ... >
,> That's why I suggested doing it by hand first. It would immediately ,> get (I hope) the OP to raise some questions. ,> ,> Clay My thought provoking approach is to ask, "What size circle?" Dale B. Dalrymple