DSPRelated.com
Forums

Complex FFT in DSP vs Matlab

Started by Unknown February 14, 2007
Hi, everyone!

I use TMS320c6713 DSP.
I compared result of complex fft library in TI DSP with result of
complex fft in Matlab.
Those waveform in frequency domain are similar, but exactly not
matched.

It means..
Range of result in DSP library is wider than one in Matlab.

Why?



Regards.

jaeper@gmail.com wrote:
> Hi, everyone! > > I use TMS320c6713 DSP. > I compared result of complex fft library in TI DSP with result of > complex fft in Matlab. > Those waveform in frequency domain are similar, but exactly not > matched. > > It means.. > Range of result in DSP library is wider than one in Matlab. > > Why? > > > > Regards. >
Because the MathWorks and TI used different algorithms. A more specific answer depends on the details of the implementations in both MatLab and the TI library -- and you can bet that you'll never get the MathWorks to cough up their code. If it really matters -- code it yourself. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/ "Applied Control Theory for Embedded Systems" came out in April. See details at http://www.wescottdesign.com/actfes/actfes.html
On Feb 14, 9:08 pm, Tim Wescott <t...@seemywebsite.com> wrote:
> Because the MathWorks and TI used different algorithms. A more specific > answer depends on the details of the implementations in both MatLab and > the TI library -- and you can bet that you'll never get the MathWorks to > cough up their code.
Actually, you can download MathWorks' underlying FFT code from www.fftw.org
stevenj@alum.mit.edu wrote:

> On Feb 14, 9:08 pm, Tim Wescott <t...@seemywebsite.com> wrote: > >>Because the MathWorks and TI used different algorithms. A more specific >>answer depends on the details of the implementations in both MatLab and >>the TI library -- and you can bet that you'll never get the MathWorks to >>cough up their code. > > > Actually, you can download MathWorks' underlying FFT code from www.fftw.org >
Well, good for them. Is this inside information, or does the MathWorks publicize the fact that they use fftw? -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/ "Applied Control Theory for Embedded Systems" came out in April. See details at http://www.wescottdesign.com/actfes/actfes.html
<jaeper@gmail.com> wrote in message 
news:1171504053.322062.75200@m58g2000cwm.googlegroups.com...
> Hi, everyone! > > I use TMS320c6713 DSP. > I compared result of complex fft library in TI DSP with result of > complex fft in Matlab. > Those waveform in frequency domain are similar, but exactly not > matched. > > It means.. > Range of result in DSP library is wider than one in Matlab. > > Why?
As far as I know, Matlab uses greater precision arithmetic... Fred
On Thu, 15 Feb 2007 05:10:18 -0000, Tim Wescott <tim@seemywebsite.com>  
wrote:

> stevenj@alum.mit.edu wrote: > >> On Feb 14, 9:08 pm, Tim Wescott <t...@seemywebsite.com> wrote: >> >>> Because the MathWorks and TI used different algorithms. A more >>> specific >>> answer depends on the details of the implementations in both MatLab and >>> the TI library -- and you can bet that you'll never get the MathWorks >>> to >>> cough up their code. >> Actually, you can download MathWorks' underlying FFT code from >> www.fftw.org >> > Well, good for them. Is this inside information, or does the MathWorks > publicize the fact that they use fftw?
It's mentioned on the MATLAB help page for fft(). In fact, they even go so far as to provide direct access to the underlying FFTW API via the fftw() function. -- Oli
I can remember, that we had a similar problem one day: MATLAB and DSP
(exactly the same you are using) and thought it was a precision-topic
(single on the dsp), but after some nasty debugging sessions we almost had
a perfect fit - the remaining perturbation definitly was about precision.
And actually the result of an fft is something well- and uniquely defined,
so if you don't mess up with ranges and the compared alg's are not extremly
numerical unstable, the results have to fit.
.. or am I wrong?

best regards,
Thomas



>Hi, everyone! > >I use TMS320c6713 DSP. >I compared result of complex fft library in TI DSP with result of >complex fft in Matlab. >Those waveform in frequency domain are similar, but exactly not >matched. > >It means.. >Range of result in DSP library is wider than one in Matlab. > >Why? > > > >Regards. > >
quaste wrote:
(top posting fixed)
> > >>Hi, everyone! >> >>I use TMS320c6713 DSP. >>I compared result of complex fft library in TI DSP with result of >>complex fft in Matlab. >>Those waveform in frequency domain are similar, but exactly not >>matched. >> >>It means.. >>Range of result in DSP library is wider than one in Matlab. >> >>Why? >> >> >> >>Regards. >> >> > > I can remember, that we had a similar problem one day: MATLAB and DSP > (exactly the same you are using) and thought it was a precision-topic > (single on the dsp), but after some nasty debugging sessions we almost had > a perfect fit - the remaining perturbation definitly was about precision. > And actually the result of an fft is something well- and uniquely defined, > so if you don't mess up with ranges and the compared alg's are not extremly > numerical unstable, the results have to fit. > .. or am I wrong? >
I wouldn't be surprised to see things scaled differently, by 2 or 2^N or 2^(N/2). But barring problems with precision and overflow -- which I also wouldn't be surprised to see -- they should, indeed, be the same. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/ "Applied Control Theory for Embedded Systems" came out in April. See details at http://www.wescottdesign.com/actfes/actfes.html
On Feb 15, 10:38 am, "quaste" <thomas.wald...@ctr.at> wrote:
> I can remember, that we had a similar problem one day: MATLAB and DSP > (exactly the same you are using) and thought it was a precision-topic > (single on the dsp), but after some nasty debugging sessions we almost had > a perfect fit - the remaining perturbation definitly was about precision. > And actually the result of an fft is something well- and uniquely defined, > so if you don't mess up with ranges and the compared alg's are not extremly > numerical unstable, the results have to fit. > .. or am I wrong?
Two caveats: * First, there are different conventions for defining the FFT, in the normalization and in the sign of the exponent. If your DSP's FFT convention is different from Matlab's, they will give different results regardless of precision. Once you know the conventions, however, it is trivial to convert in order to compare the two results. * Second, the results only have to fit to within the numerical accuracy...the question is, what is the accuracy. A well-designed floating-point FFT, such as Matlab's, has rms numerical errors that grow as O(sqrt(log(N)))...for all except enormous sizes, this means it is accurate to nearly machine precision (14-15 significant digits). (See also www.fftw.org/accuracy). If your DSP chip uses a fixed-point FFT algorithm, the rms errors grow much faster, as O(sqrt(N)), so its errors are almost certainly much worse than Matlab's double-precision results. Steven
<stevenj@alum.mit.edu> wrote in message 
news:1171559284.478944.229240@v45g2000cwv.googlegroups.com...
> On Feb 15, 10:38 am, "quaste" <thomas.wald...@ctr.at> wrote: >> I can remember, that we had a similar problem one day: MATLAB and DSP >> (exactly the same you are using) and thought it was a precision-topic >> (single on the dsp), but after some nasty debugging sessions we almost >> had >> a perfect fit - the remaining perturbation definitly was about precision. >> And actually the result of an fft is something well- and uniquely >> defined, >> so if you don't mess up with ranges and the compared alg's are not >> extremly >> numerical unstable, the results have to fit. >> .. or am I wrong? > > Two caveats: > > * First, there are different conventions for defining the FFT, in the > normalization and in the sign of the exponent. If your DSP's FFT > convention is different from Matlab's, they will give different > results regardless of precision. Once you know the conventions, > however, it is trivial to convert in order to compare the two results. > > * Second, the results only have to fit to within the numerical > accuracy...the question is, what is the accuracy. A well-designed > floating-point FFT, such as Matlab's, has rms numerical errors that > grow as O(sqrt(log(N)))...for all except enormous sizes, this means it > is accurate to nearly machine precision (14-15 significant digits). > (See also www.fftw.org/accuracy). If your DSP chip uses a fixed-point > FFT algorithm, the rms errors grow much faster, as O(sqrt(N)), so its > errors are almost certainly much worse than Matlab's double-precision > results. > > Steven
Steven, The DSP supports floating point - IEEE I believe. Fred