Escolar Documentos
Profissional Documentos
Cultura Documentos
W. Rose 2013-04-06
Signalx(t)t=0toT
T=samplinginterval=1/fsamp
N=numberofsamples
T=NT
Simplespectrumestimate
S(f)=powerspectrum=k||X(f)||2
X(f)=discreteFouriertransformofx(t)(X(f)iscomplex)
where f=0tofN/2=0tofsamp/2(singlesided)
f=0tof(N1)(twosided)
andwhere
f=1/T
SpectrumDetails
S(f)=powerspectrum=k||X(f)||2
where X(f)=discreteFouriertransformofx(t)
X(f)iscomplex;S(f)isreal
If x(t)hasNpoints
Then twosidedspectrumhasNpoints
onesidedspectrumhasN/2+1points
k=normalizingfactor;dependsonparticularroutineusedtocalculate
spectrum:singleordoublesided,peakorRMSunits,etc.(1)
Exampleofthesimplespectrumestimate
Suppose
where
f=1,d1=4/,d3=4/(3).424,d5=4/(5).255.
Thismeansx(t)iscomprisedofsinusoidalcomponentswith
frequenciesof1,3,and5Hz,withamplitudesgivenbyd1,d3,
andd5.*
Supposealsothatthesamplingrateisfsamp=100Hz,i.e.
dT=1/fsamp=0.01s,andsupposethatwecollectdatafor5
seconds(Ttotal=5s).
*dk=4/(k)=amplitudesfor1Vsquarewave(kodd).
Department of Kinesiology and Applied Physiology
Exampleofthesimplespectrumestimate
Matlabcodetomaketandx(t)andplot:
dt=0.01
t=(0:499)*dt;
f=1;
d1=4/pi;
d3=4/(3*pi);
d5=4/(5*pi);
x=d1*sin(2*pi*f*t)
+d3*sin(2*pi*3*f*t)
+d5*sin(2*pi*5*f*t);
plot(t,x,.r-);
Exampleofthesimplespectrumestimate
Matlabcodetocomputeamplitudespectrumusingfft(x):
X=fft(x);
Xamp_2s=abs(X);
N=length(x);
T=N*dt;
df=1/T;
freqs=(0:N-1)*df;
plot(freqs,Xamp_2s,.r-);
Note:fft(x)returnsa
2sidedspectrum,as
isevidentfromthe
graphbelow.
Amplitudespectrum
(twosided)
Exampleofthesimplespectrumestimate
Thenonzerovalues|X(f)|=dkN/2,wheredk=theamplitudeof
thesinusoidusedtocontructx(t),asshownonanearlierslide.
Thisshowsthatvaluesreturnedbyfft(x)scalelikeN/2,except
atf=0andf=fNyquist=fsamp/2,atwhichfrequenciesthevalues
returnedbyfft(x)scalelikeN(notshowninthisexample).
Thedividebytwoscalefactorisduetothefactthatthe
energythatstartedoutat1Hzissplitbetween1Hzand99Hz
inthetwosidedspectrum.
Amplitudespectrum
(twosided)
Exampleofthesimplespectrumestimate
Computethesinglesidedpowerspectrum.DividebyNatf=0and
f=fNyquist;dividebyN/2atallotherfrequencies.
S=([Xamp_2s(1) Xamp_2s(2:N/2)*2 Xamp_2s(N/2+1)]/N).^2;
freq1s=(0:N/2)*df;
plot(freq1s,S,'.r-');
xlabel('Frequency (Hz)'); ylabel('Power');
Singlesidedpowerspectrum
ABetterSpectrumEstimate
Overview
1.Dividethetimedomainrecordintoblocks.
2.Findpowerspectrumofeachblock.
3.Averagethepowerspectra,frequencybyfrequency.
ABetterSpectrumEstimate:Details
1. Dividetimedomainrecordintosegmentsofequal
length.Ifthereareqnonoverlappingsegments,then
alsoincludeq1halfoverlappedsegments.
Example:Totaldatarecordlength=Ntot=4000points.
Investigatorchoosesq=4.Theneachsegmenthas
lengthNseg=Ntot/q=1000points.Thefournon
overlappingblocksstartatpoints0,1000,2000,3000.
Threehalfoverlappedblocksstartat500,1500,2500.
Totalnumberofsegments=2q1=7.
ABetterSpectrumEstimate:Details
2.Findpowerspectrumofeachsegment.
Beforecomputingspectrumofeachsegment,remove
lineartrend,resultinginblockwithzeromeanvalue
andzeroslope.Someprefertoremoveonlythemean
valueandnotthelineartrend(ifany).
WindowthedatainthesegmentwithHannor
Hammingwindow.
Computepowerspectrumofwindoweddata.
Correctpowerspectrumforthelossofpowercaused
bythewindow:
Hannwindow:multiplypowerestimatesby8/3.
Hamming:multiplypowerestimatesby2.516.
Department of Kinesiology and Applied Physiology
ABetterSpectrumEstimate:Details
3. Averagethepowerspectra,frequencybyfrequency.
Savg(f)=(1/(2q1))*Sum(i=1to2q1){Si(f)}
whereSi(f)=poweratfrequencyfoftheithsegment
ScaleFactorsforPowerSpectrumEstimates
singlesidedspectrum:Ateachnonzerofrequency(fromfto
highestfrequencybelowthehalfwaypoint,whichisf=f samp/2),
multiplythetwosidedestimateatthatfrequencyby2togetthesingle
sidedpowerestimate.Thesinglesidedspectrumonlygoestof samp/2.At
f=0andatf=fsamp/2,thesinglesidedestimateisthesameasthetwo
sidedestimate.
SeeLabviewhelpforPowerSpectrum.vi(returnstwosidedspectrum)
andAutoPowerSpectrum.vi.(returnsonesidedspectrum).
RMS units
This definition was chosen because it equals the power dissipated in a 1 ohm
resistor by a current I=x(t). If x(t)=Acos(2ft), and if T=a whole number of
cycles, then we can solve the integral to show that P=A2/2 if f>0, and P=A2 if
f=0.
It is called root mean square, because a time-varying signal has much power
as a steady signal whose amplitude equals the square root of the mean of the
squared amplitude of the time varying signal.
PartialfrontpanelofFFT_and_Power_Spectrum_Units.vi
ExampleVIinLV2012
OutputfromFFT.viscaleslikerecordlengthn.OtherVIsreturnoutputwhichhis
independentofrecordlength.FFTandPower_Spectrumreturntwosidedspectra,
whichiswhytheirnonDCscalingisdividedby2.TheotherVIsreturnonesided
spectra.FFT_Power_Spectral_Densitydivideseachpowerspectrumestimateby
f,thefrequencyspacingbetweenestimates(f=spectralwidthofeachestimate).
Department of Kinesiology and Applied Physiology