Re: Engineering requests
- To: mathgroup at smc.vnet.net
- Subject: [mg125351] Re: Engineering requests
- From: roby <roby.nowak at gmail.com>
- Date: Thu, 8 Mar 2012 04:40:26 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jiqflj$3o$1@smc.vnet.net>
On 2 Mrz., 13:49, "McHale, Paul" <Paul.McH... at excelitas.com> wrote: > So, here are some problems we face, but don't have great answers for in Mathematica. > 6. ListFFT[]. This is an unusual request. 99% of the data we engineers deal with is evenly spaced sample data. Most of the FFT activity I have ever seen involves getting the FFT from a list of data and plotting Real[]. Simplified, I know. Since most of our data is in the form {{t1, sample1},{t2, sample2},{t3, sample3}} the time information is embedded. In fact, all information is available to perform an FFT. Just saying it makes life easier. Could offer options like Results->{Real, Imaginary, Both} > > Kind Regards, > Paul > Hi Paul, by plotting Real[ ] you certainly had plotting Re[ ] in mind which is not fundamental different form Im[ ], most of the FFT activity I have ever seen involves getting the FFT from a list of data and plotting Abs[ ]. Could it be that you are lookoing for spectral amlitude (and or power) analysis with correct frequency information ? the functions below take a 1D list of data samples as first parameter and a second optional scalar parameter specifying the SamplingPeriod, they return a spectrum as list of {frequency, amplitude} resp. {frequency, power} pairs if a SamplingPeriod is specifyed. FourierSpectrum[ ] first calculates the mathematical spectrum containing positive as well as negative frequencies. For real input data one can add the positive and the conjugate of the negative frequncies to get a physical spectrum of positive only frequencies. By this method there is no special treatment neccesary to obtain the correct DC as well as the correct max. frequency term. Appears to be more physical than just litter the negative frequencies and adjust the DC and max. frequency terms. FourierSpectrum[d_,SampligPeriod_: False]:=Module[{q2=Quotient[Length[d],2],m2=Mod[Length[d],2]}, Fourier[d,FourierParameters->{-1,1}]//Join[#[[1;;1]],#[[2;;q2+m2]] +Conjugate@Reverse@(#[[q2+2;;]]),#[[q2+1;;q2+1-m2]]]&// Abs//If[SampligPeriod=!=False,{1/(2 SampligPeriod (Length@# -1)) Range[0,Length@#-1],#}//Transpose, #]& ] FourierPSpectrum[d_,SampligPeriod_: False]:=FourierSpectrum[d,SampligPeriod]//If[SampligPeriod=!=False, {First@#,(Last@#)^2}&/@#,#^2]& Robert