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

# Circular convolution

Started by ●April 24, 2011

Reply by ●April 25, 20112011-04-25

>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

Reply by ●April 25, 20112011-04-25

On Apr 24, 2:07�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 youIt is likly most instructive to actually do this by hand and then work on programming Matlab to get a similar result.

Reply by ●April 25, 20112011-04-25

On Apr 25, 9:51�am, Clay <c...@claysturner.com> wrote:> On Apr 24, 2:07�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.

Reply by ●April 25, 20112011-04-25

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

Reply by ●April 25, 20112011-04-25

On Apr 25, 4:49�pm, dvsarwate <dvsarw...@yahoo.com> 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 SarwateThat's why I suggested doing it by hand first. It would immediately get (I hope) the OP to raise some questions. Clay

Reply by ●April 25, 20112011-04-25

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

Reply by ●April 25, 20112011-04-25

On Apr 25, 5:38�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.

Reply by ●April 25, 20112011-04-25

On Apr 25, 10:49�pm, dvsarwate <dvsarw...@yahoo.com> 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)?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

Reply by ●April 26, 20112011-04-26