Reply by Andor June 27, 20052005-06-27
Fred wrote:

>It's a little hard to understand why you would correlate two spectra unless >you tell us.
I thought it strange too. Slow Windowing (as opposed to Fast Convolution) :-) ? Regards, Andor
Reply by June 27, 20052005-06-27
Thank you for all of your replies.

So as i said, I am trying to obtain the convolution of two spectra. I
could simply get the product of the functions in time domain, but for
the work i am doing I need to look at the frequency components, because
later on i will try to eliminate or add components and see what i get
from the convolution.

I understand the issue about the Matlab index, but now i have a
thought... What i have done so far is consider the first 300 harmonics
of each spectra and convolve them. I have ignored the dc component in
each function; however i know there is one in each. Could ignoring this
DC in the convolution be the cause of my close to, but not exact
results?

Thank you for all the help!

Reply by Rune Allnor June 27, 20052005-06-27

stuffed_penguin@yahoo.com wrote:
> Hello. Thank you for your reply. It all makes sense. Yes, most of the > energy is in those first 300 harmonics. I am using the exponential form > of the coeficients. > > I performed the convolution of my two spectra both with Matlab and with > a homemade loop. Both yielded the same results, however they didn't > yield exactly what i expected. It is close, but not exact. One of the > peculiarities is that in my output spectrum, the spectra seem to be > shifted by 1 harmonic. For example, what i expected to appear in the > 30th harmonic appears in the 31st, and so on for all the rest. I am > simply plotting the results I obtain without making any modification. > > I have 2 input arrays going from 1 to 300. and my output array goes > from 1 to 599. > > any ideas where i have screwed up? Thanks agan for your help and time.
It could be that the indexing in matlab confuses you. The DC coefficient is usually termed X(0) in the formulas, but in matlab it would appear in X(1), since matlab can't index from 0. Rune
Reply by Fred Marshall June 27, 20052005-06-27
<stuffed_penguin@yahoo.com> wrote in message 
news:1119837774.729322.24650@g43g2000cwa.googlegroups.com...
> Hello. Thank you for your reply. It all makes sense. Yes, most of the > energy is in those first 300 harmonics. I am using the exponential form > of the coeficients. > > I performed the convolution of my two spectra both with Matlab and with > a homemade loop. Both yielded the same results, however they didn't > yield exactly what i expected. It is close, but not exact. One of the > peculiarities is that in my output spectrum, the spectra seem to be > shifted by 1 harmonic. For example, what i expected to appear in the > 30th harmonic appears in the 31st, and so on for all the rest. I am > simply plotting the results I obtain without making any modification. > > I have 2 input arrays going from 1 to 300. and my output array goes > from 1 to 599.
Exactly- as I mentioned. Did you expect anything different? If so, why?
> > any ideas where i have screwed up? Thanks agan for your help and time. >
It appears that your indices are off by 1. Easy to do. You didn't say why you want to do this in the first place. So, maybe the answer is related to the objective and how you are approaching it. It's a little hard to understand why you would correlate two spectra unless you tell us. Fred
Reply by June 26, 20052005-06-26
Hello. Thank you for your reply. It all makes sense. Yes, most of the
energy is in those first 300 harmonics. I am using the exponential form
of the coeficients.

I performed the convolution of my two spectra both with Matlab and with
a homemade loop. Both yielded the same results, however they didn't
yield exactly what i expected. It is close, but not exact. One of the
peculiarities is that in my output spectrum, the spectra seem to be
shifted by 1 harmonic. For example, what i expected to appear in the
30th harmonic appears in the 31st, and so on for all the rest. I am
simply plotting the results I obtain without making any modification.

I have 2 input arrays going from 1 to 300. and my output array goes
from 1 to 599.

any ideas where i have screwed up? Thanks agan for your help and time.

Reply by Fred Marshall June 26, 20052005-06-26
"timelapse" <stuffed_penguin@yahoo.com> wrote in message 
news:1119714029.116735.274020@g43g2000cwa.googlegroups.com...
> Hello. I would like to obtain the convolution of two spectra. I have > the complex form Fourier coefficients for the first 300 harmonics of > each spectra. I was looking at the definition of convolution in one of > my books and the sumation term goes from -infinity to infinity. > > Can I obtain a good accurate convolution with the terms i have or do I > have to also calculate the terms for the negative frequencies?
Fourier Series coefficients are generally for sine and cosine terms. So, there are no "negative frequencies". If you convert sine and cosine terms to exponential form, then there are negative frequencies. I don't think you can convolve the sine / cosine coefficients as such without using conversions on them. The Finite Discrete Fourier Transform results in coefficients for the exponential form. There are "negative" frequency terms that show up between fs/2 and fs .... or, if you like ... below fs and above fs/2. The even part of the coefficients yields the cosine terms. The odd part of the coefficients yields the sine terms. The real part is even if the time series is real. The imaginary part is odd if the time series is real. So, you need to know which form of the "series" you're using. Re: "Good / Accurate": Probably yes but maybe no. Here's why: You have 300 coefficients. Are they the principal ones? Is Parseval's Theorem met (nearly met?) with them in relation to the time series? If so, then probably yes. But, if the 300 coefficients don't represent the majority of the energy in the signal then maybe not. In other words, you can't leave out significant parts of the signal and expect to get meaningful results. Most real world signals run out of energy at the higher frequencies - unless they are "bandpass" signals and are centered at some high frequency. In that case the observation generally shifts to the bandwidth of the signal around that center frequency. You probably know if this is or is not the case.
> > If all the terms i have are for n = 1 to 300, would those then be the > limits of the summation?
The result of convolving 2 sequences of 300 samples is a sequence that is 599 samples long. There can be no more than 300 nonzero terms in any set of products and, thus, nonzero terms in a sum. A reasonable implementation would sum over those only - that is, 300 at a time.
> > Can I use the Matlab function 'conv()' to perform the convolution if I > store the two spectra in arrays of the same length?
I don't see why not. Just recognize that the resulting array will be longer than either of the "input" arrays. Fred
Reply by timelapse June 25, 20052005-06-25
Hello. I would like to obtain the convolution of two spectra. I have
the complex form Fourier coefficients for the first 300 harmonics of
each spectra. I was looking at the definition of convolution in one of
my books and the sumation term goes from -infinity to infinity.

Can I obtain a good accurate convolution with the terms i have or do I
have to also calculate the terms for the negative frequencies?

If all the terms i have are for n = 1 to 300, would those then be the
limits of the summation?

Can I use the Matlab function 'conv()' to perform the convolution if I
store the two spectra in arrays of the same length?

Thank you for your help!