Continuous Wavelet Transform MATLAB & Simulink
Continuous Wavelet Transform MATLAB & Simulink
ContinuousWaveletTransformMATLAB&Simulink
ContinuousWaveletTransform
DefinitionoftheContinuousWaveletTransform
LiketheFouriertransform,thecontinuouswavelettransform(CWT)usesinnerproductstomeasurethesimilaritybetween
jt
asignalandananalyzingfunction.IntheFouriertransform,theanalyzingfunctionsarecomplexexponentials, e
.The
resultingtransformisafunctionofasinglevariable,.IntheshorttimeFouriertransform,theanalyzingfunctionsare
jt
windowedcomplexexponentials, w(t)e
,andtheresultinafunctionoftwovariables.TheSTFTcoefficients, F (, ),
representthematchbetweenthesignalandasinusoidwithangularfrequencyinanintervalofaspecifiedlength
centeredat.
IntheCWT,theanalyzingfunctionisawavelet,.TheCWTcomparesthesignaltoshiftedandcompressedorstretched
versionsofawavelet.Stretchingorcompressingafunctioniscollectivelyreferredtoasdilationorscalingandcorresponds
tothephysicalnotionofscale.Bycomparingthesignaltothewaveletatvariousscalesandpositions,youobtaina
functionoftwovariables.Thetwodimensionalrepresentationofaonedimensionalsignalisredundant.Ifthewaveletis
complexvalued,theCWTisacomplexvaluedfunctionofscaleandposition.Ifthesignalisrealvalued,theCWTisareal
valuedfunctionofscaleandposition.Forascaleparameter,a>0,andposition,b,theCWTis:
t b
) dt
a
f (t) G (
a
where denotesthecomplexconjugate.NotonlydothevaluesofscaleandpositionaffecttheCWTcoefficients,the
choiceofwaveletalsoaffectsthevaluesofthecoefficients.
Bycontinuouslyvaryingthevaluesofthescaleparameter,a,andthepositionparameter,b,youobtainthecwtcoefficients
C(a,b).Notethatforconvenience,thedependenceoftheCWTcoefficientsonthefunctionandanalyzingwavelethasbeen
suppressed.
Multiplyingeachcoefficientbytheappropriatelyscaledandshiftedwaveletyieldstheconstituentwaveletsoftheoriginal
signal.
TherearemanydifferentadmissiblewaveletsthatcanbeusedintheCWT.Whileitmayseemconfusingthatthereareso
manychoicesfortheanalyzingwavelet,itisactuallyastrengthofwaveletanalysis.Dependingonwhatsignalfeatures
youaretryingtodetect,youarefreetoselectawaveletthatfacilitatesyourdetectionofthatfeature.Forexample,ifyouare
tryingtodetectabruptdiscontinuitiesinyoursignal,youmaychooseonewavelet.Ontheotherhand,ifyouareinteresting
infindingoscillationswithsmoothonsetsandoffsets,youarefreetochooseawaveletthatmorecloselymatchesthat
behavior.
Scale
Liketheconceptoffrequency,scaleisanotherusefulpropertyofsignalsandimages.Forexample,youcananalyze
temperaturedataforchangesondifferentscales.Youcanlookatyeartoyearordecadetodecadechanges.Ofcourse,
youcanexaminefiner(daytoday),orcoarserscalechangesaswell.Someprocessesrevealinterestingchangesonlong
time,orspatialscalesthatarenotevidentonsmalltimeorspatialscales.Theoppositesituationalsohappens.Someof
ourperceptualabilitiesexhibitscaleinvariance.Yourecognizepeopleyouknowregardlessofwhetheryoulookatalarge
portrait,orsmallphotograph.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
1/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Togobeyondcolloquialdescriptionssuchas"stretching"or"shrinking"weintroducethescalefactor,oftendenotedbythe
lettera.Thescalefactorisainherentlypositivequantity,a>0.Forsinusoids,theeffectofthescalefactorisveryeasyto
see.
Insin(at),thescaleistheinverseoftheradianfrequency,a.
Thescalefactorworksexactlythesamewithwavelets.Thesmallerthescalefactor,themore"compressed"thewavelet.
Conversely,thelargerthescale,themorestretchedthewavelet.Thefollowingfigureillustratesthisforwaveletsatscales
1,2,and4.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
2/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Thisgeneralinverserelationshipbetweenscaleandfrequencyholdsforsignalsingeneral.SeeCWTasaFiltering
TechniqueandScaleandFrequencyformoreinformationontherelationshipbetweenscaleandfrequency.
Notonlyisatimescalerepresentationadifferentwaytoviewdata,itisaverynaturalwaytoviewdataderivedfroma
greatnumberofnaturalphenomena.
ScaleandFrequency
Thereisclearlyarelationshipbetweenscaleandfrequency.Recallthathigherscalescorrespondtothemost"stretched"
wavelets.Themorestretchedthewavelet,thelongertheportionofthesignalwithwhichitisbeingcompared,and
thereforethecoarserthesignalfeaturesmeasuredbythewaveletcoefficients.
Tosummarize,thegeneralcorrespondencebetweenscaleandfrequencyis:
LowscaleaCompressedwaveletRapidlychangingdetailsHighfrequency.
HighscaleaStretchedwaveletSlowlychanging,coarsefeaturesLowfrequency.
Whilethereisageneralrelationshipbetweenscaleandfrequency,nopreciserelationshipexists.Usersfamiliarwith
Fourieranalysisoftenwanttodefineamappingbetweenawaveletatagivenscalewithaspecifiedsamplingperiodtoa
frequencyinhertz.Youcanonlydothisinageneralsense.Therefore,itisbettertotalkaboutthepseudofrequency
correspondingtoascale.TheWaveletToolboxsoftwareprovidestwofunctionscentfrqandscal2frq,whichenable
youtofindtheseapproximatescalefrequencyrelationshipsforspecifiedwaveletsandscales.
ThebasicapproachidentifiesthepeakpowerintheFouriertransformofthewaveletasitscenterfrequencyanddivides
thatvaluebytheproductofthescaleandthesamplinginterval.Seescal2frqfordetails.Thefollowingexampleshows
thematchbetweentheestimatedcenterfrequencyofthedb8waveletandasinusoidofthesamefrequency.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
3/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
TherelationshipbetweenscaleandfrequencyintheCWTisalsoexploredinCWTasaFilteringTechnique.
Shifting
Shiftingawaveletsimplymeansdelaying(oradvancing)itsonset.Mathematically,delayingafunctionf(t)bykis
representedbyf(tk):
CWTasaWindowedTransform
InShortTimeFourierTransform,theSTFTisdescribedasawindowingofthesignaltocreatealocalfrequencyanalysis.A
shortcomingoftheSTFTapproachisthatthewindowsizeisconstant.Thereisatradeoffinthechoiceofwindowsize.A
longertimewindowimprovesfrequencyresolutionwhileresultinginpoorertimeresolutionbecausetheFouriertransform
losesalltimeresolutionoverthedurationofthewindow.Conversely,ashortertimewindowimprovestimelocalization
whileresultinginpoorerfrequencyresolution.
Waveletanalysisrepresentsthenextlogicalstep:awindowingtechniquewithvariablesizedregions.Waveletanalysis
allowstheuseoflongtimeintervalswhereyouwantmorepreciselowfrequencyinformation,andshorterregionswhere
youwanthighfrequencyinformation.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
4/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Thefollowingfigurecontraststime,frequency,timefrequency,andtimescalerepresentationsofasignal.
CWTasaFilteringTechnique
Thecontinuouswavelettransform(CWT)computestheinnerproductofasignal, f (t) ,withtranslatedanddilatedversions
ofananalyzingwavelet, (t). ThedefinitionoftheCWTis:
t b
) dt
a
f (t) G (
a
YoucanalsointerprettheCWTasafrequencybasedfilteringofthesignalbyrewritingtheCWTasaninverseFourier
transform.
1
2
f ()
a ((a)) e
jb
where f () and ()
aretheFouriertransformsofthesignalandthewavelet.
Fromtheprecedingequations,youcanseethatstretchingawaveletintimecausesitssupportinthefrequencydomainto
shrink.Inadditiontoshrinkingthefrequencysupport,thecenterfrequencyofthewaveletshiftstowardlowerfrequencies.
Thefollowingfiguredemonstratesthiseffectforahypotheticalwaveletandscale(dilation)factorsof1,2,and4.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
5/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
ThisdepictstheCWTasabandpassfilteringoftheinputsignal.CWTcoefficientsatlowerscalesrepresentenergyinthe
inputsignalathigherfrequencies,whileCWTcoefficientsathigherscalesrepresentenergyintheinputsignalatlower
frequencies.However,unlikeFourierbandpassfiltering,thewidthofthebandpassfilterintheCWTisinversely
proportionaltoscale.ThewidthoftheCWTfiltersdecreaseswithincreasingscale.Thisfollowsfromtheuncertainty
relationshipsbetweenthetimeandfrequencysupportofasignal:thebroaderthesupportofasignalintime,thenarrower
itssupportinfrequency.Theconverserelationshipalsoholds.
Inthewavelettransform,thescale,ordilationoperationisdefinedtopreserveenergy.Topreserveenergywhileshrinking
thefrequencysupportrequiresthatthepeakenergylevelincreases.Thequalityfactor,orQfactorofafilteristheratioofits
peakenergytobandwidth.Becauseshrinkingorstretchingthefrequencysupportofawaveletresultsincommensurate
increasesordecreasesinitspeakenergy,waveletsareoftenreferredtoasconstantQfilters.
DFTBasedContinuousWaveletTransform
TheequationintheprecedingsectiondefinedtheCWTastheinverseFouriertransformofaproductofFouriertransforms.
1
2
f ()
a (a)e
jb
ThetimevariableintheinverseFouriertransformisthetranslationparameter,b.
ThissuggeststhatyoucancomputetheCWTwiththeinverseFouriertransform.Becausethereareefficientalgorithmsfor
thecomputationofthediscreteFouriertransformanditsinverse,youcanoftenachieveconsiderablesavingsbyusingfft
andifftwhenpossible.
ToobtainapictureoftheCWTintheFourierdomain,startwiththedefinitionofthewavelettransform:
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
6/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
t b
)dt
a
f (t)(
Ifyoudefine:
1
a(t) = G (t/a)
a
youcanrewritethewavelettransformas
(f a)(b) =
whichexplicitlyexpressestheCWTasaconvolution.
ToimplementthediscretizedverionoftheCWT,assumethattheinputsequenceisalengthNvector,x[n].Thediscrete
versionoftheprecedingconvolutionis:
W a[b] =
N1
n=0
x[n] a[b n]
ToobtaintheCWT,itappearsyouhavetocomputetheconvolutionforeachvalueoftheshiftparameter,b,andrepeatthis
processforeachscale,a.
However,ifthetwosequencesarecircularlyextended(periodizedtolengthN),youcanexpressthecircularconvolution
asaproductofdiscreteFouriertransforms.TheCWTistheinverseFouriertransformoftheproduct
W a(b) =
1
N
2a
t
N1
X (2k/Nt) (a2k/Nt)e
j2kb/N
k=0
wheretisthesamplinginterval(period).
ExpressingtheCWTasaninverseFouriertransformenablesyoutousethecomputationallyefficientfftandifft
algorithmstoreducethecostofcomputingconvolutions.
ThecwtftfunctionimplementstheCWTusinganFFTbasedalgorithm.Seecwtftinfoforinformationpertainingtothe
supportedanalyzingwavelets.
InverseContinuousWaveletTransform
TheicwtftfunctionimplementstheinverseCWT.UsingicwtftrequiresthatyouobtaintheCWTfromcwtft.The
WaveletToolboxdoesnotsupporttheinverseCWTforageneralCWTobtainedusingcwt.
BecausetheCWTisaredundanttransform,thereisnotauniquewaytodefinetheinverse.TheinverseCWTimplemented
intheWaveletToolboxutilizesadiscreteversionofthesingleintegralformuladuetoMorlet.
TheinverseCWTisclassicallypresentedinthedoubleintegralform.AssumeyouhaveawaveletwithaFouriertransform
thatsatisfiestheadmissibilitycondition:
C =
2
|()|
d
||
<
Forwaveletssatisfyingtheadmissibilityconditionandfiniteenergyfunctions,f(t),youcandefinetheinverseCWTas:
f (t) =
1
C
da
2
a
Foranalyzingwaveletsandfunctionssatisfyingthefollowingconditions,asingleintegralformulafortheinverseCWT
exists.Theseconditionsare:
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
7/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Theanalyzedfunction,f(t),isrealvaluedandtheanalyzingwavelethasarealvaluedFouriertransform.
Theanalyzedfunction,f(t),isrealvaluedandtheFouriertransformoftheanalyzingwavelethassupportonlyontheset
ofnonnegativefrequencies.Thisisreferredtoasananalyticwavelet.AfunctionwhoseFouriertransformonlyhas
supportonthesetofnonnegativefrequenciesmustbecomplexvalued.
Theprecedingconditionsconstrainthesetofpossibleanalyzingwavelets.Ifyouinspectthelistofwaveletssupportedby
cwtft,eachwaveletiseitheranalyticorhasarealvaluedFouriertransform.Becausethetoolboxonlysupportsthe
analysisofrealvaluedfunctions,therealvaluedconditionontheanalyzedfunctionisalwayssatisfied.
Tomotivatethesingleintegralformula,let 1and 2betwowaveletsthatsatisfythefollowingtwowaveletadmissibility
condition:
() ()
1 2
d <
Definetheconstant:
() ()
1
2 d
C , =
1 2
INotethattheaboveconstantmaybecomplexvalued.Letf(t)andg(t)betwofiniteenergyfunctions.Ifthetwowavelet
admissibilityconditionissatisfied,thefollowingequalityholds:
,
1 2
< f, g >=
da
2
a
f (t) = 2 Re
C
,
1
whereRe{}denotestherealpart.
da
3/2
a
TheprecedingequationdemonstratesthatyoucanreconstructthesignalbysummingthescaledCWTcoefficientsoverall
scales.
BysummingthescaledCWTcoefficientsfromselectscales,youobtainanapproximationtotheoriginalsignal.Thisis
usefulinsituationswhereyourphenomenonofinterestislocalizedinscale.
icwtftimplementsadiscretizedversionoftheaboveintegral.
ContinuousWaveletTransformAlgorithm
ThefollowingoutlinesthebasicalgorithmfortheCWT:
1. Takeawaveletandcompareittoasectionatthestartoftheoriginalsignal.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
8/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
2. Calculateanumber,C,thatrepresentshowcloselycorrelatedthewaveletiswiththissectionofthesignal.Thelarger
thenumberCisinabsolutevalue,themorethesimilarity.ThisfollowsfromthefacttheCWTcoefficientsarecalculated
withaninnerproduct.SeeInnerProductsformoreinformationonhowinnerproductsmeasuresimilarity.Ifthesignal
energyandthewaveletenergyareequaltoone,Cmaybeinterpretedasacorrelationcoefficient.Notethat,in
general,thesignalenergydoesnotequaloneandtheCWTcoefficientsarenotdirectlyinterpretableascorrelation
coefficients.
AsdescribedinDefinitionoftheContinuousWaveletTransform,theCWTcoefficientsexplicitlydependonthe
analyzingwavelet.Therefore,theCWTcoefficientsaredifferentwhenyoucomputetheCWTforthesamesignalusing
differentwavelets.
3. Shiftthewavelettotherightandrepeatsteps1and2untilyou'vecoveredthewholesignal.
4. Scale(stretch)thewaveletandrepeatsteps1through3.
5. Repeatsteps1through4forallscales.
InterpretingCWTCoefficients
BecausetheCWTisaredundanttransformandtheCWTcoefficientsdependonthewavelet,itcanbechallengingto
interprettheresults.
TohelpyouininterpretingCWTcoefficients,itisbesttostartwithasimplesignaltoanalyzeandananalyzingwaveletwith
asimplestructure.
Asignalfeaturethatwaveletsareverygoodatdetectingisadiscontinuity,orsingularity.Abrupttransitionsinsignalsresult
inwaveletcoefficientswithlargeabsolutevalues.
Forthesignalcreateashiftedimpulse.Theimpulseoccursatpoint500.
x=zeros(1000,1);
x(500)=1;
Forthewavelet,picktheHaarwavelet.
[~,psi,xval]=wavefun('haar',10);
plot(xval,psi);axis([011.51.5]);
title('HaarWavelet');
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
9/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
TocomputetheCWTusingtheHaarwaveletatscales1to128,enter:
CWTcoeffs=cwt(x,1:128,'haar');
CWTcoeffsisa128by1000matrix.EachrowofthematrixcontainstheCWTcoefficientsforonescale.Thereare128
rowsbecausetheSCALESinputtocwtis1:128.Thecolumndimensionofthematrixmatchesthelengthoftheinputsignal.
RecallthattheCWTofa1Dsignalisafunctionofthescaleandpositionparameters.ToproduceaplotoftheCWT
coefficients,plotpositionalongthexaxis,scalealongtheyaxis,andencodethemagnitude,orsizeoftheCWT
coefficientsascolorateachpointinthexy,ortimescaleplane.
Youcanproducethisplotusingcwtwiththeoptionalinputargument'plot'.
cwt(x,1:128,'haar','plot');
colormapjet;colorbar;
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
10/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
TheprecedingfigurewasmodifiedwithtextlabelstoexplicitlyshowwhichcolorsindicatelargeandsmallCWT
coefficients.
YoucanalsoplotthesizeoftheCWTcoefficientsin3Dwith
cwt(x,1:64,'haar','3Dplot');colormapjet;
wherethenumberofscaleshasbeenreducedtoaidinvisualization.
ExaminingtheCWToftheshiftedimpulsesignal,youcanseethatthesetoflargeCWTcoefficientsisconcentratedina
narrowregioninthetimescaleplaneatsmallscalescenteredaroundpoint500.Asthescaleincreases,thesetoflarge
CWTcoefficientsbecomeswider,butremainscenteredaroundpoint500.Ifyoutracetheborderofthisregion,itresembles
thefollowingfigure.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
11/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Thisregionisreferredtoastheconeofinfluenceofthepointt=500fortheHaarwavelet.Foragivenpoint,theconeof
influenceshowsyouwhichCWTcoefficientsareaffectedbythesignalvalueatthatpoint.
Tounderstandtheconeofinfluence,assumethatyouhaveawaveletsupportedon[C,C].Shiftingthewaveletbyband
scalingbyaresultsinawaveletsupportedon[Ca+b,Ca+b].Forthesimplecaseofashiftedimpulse, (t ) ,theCWT
coefficientsareonlynonzeroinanintervalaroundequaltothesupportofthewaveletateachscale.Youcanseethisby
consideringtheformalexpressionoftheCWToftheshiftedimpulse.
C(a, b (t ), (t)) =
t b
)dt
a
(t ) G (
a
b
)
a
= G (
a
Fortheimpulse,theCWTcoefficientsareequaltotheconjugated,timereversed,andscaledwaveletasafunctionofthe
shiftparameter,b.YoucanseethisbyplottingtheCWTcoefficientsforaselectfewscales.
subplot(311)
plot(CWTcoeffs(10,:));title('Scale10');
subplot(312)
plot(CWTcoeffs(50,:));title('Scale50');
subplot(313)
plot(CWTcoeffs(90,:));title('Scale90');
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
12/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Theconeofinfluencedependsonthewavelet.Youcanfindandplottheconeofinfluenceforaspecificwaveletwith
conofinf.
Thenextexamplefeaturesthesuperpositionoftwoshiftedimpulses, (t 300) + (t 500) .Inthiscase,usethe
Daubechies'extremalphasewaveletwithfourvanishingmoments,db4.Thefollowingfigureshowstheconeofinfluence
forthepoints300and500usingthedb4wavelet.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
13/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Lookatpoint400forscale20.Atthatscale,youcanseethatneitherconeofinfluenceoverlapsthepoint400.Therefore,
youcanexpectthattheCWTcoefficientwillbezeroatthatpointandscale.Thesignalisonlynonzeroattwovalues,300
and500,andneitherconeofinfluenceforthosevaluesincludesthepoint400atscale20.Youcanconfirmthisby
entering:
x=zeros(1000,1);
x([300500])=1;
CWTcoeffs=cwt(x,1:128,'db4');
plot(CWTcoeffs(20,:));gridon;
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
14/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Next,lookatthepoint400atscale80.Atscale80,theconesofinfluenceforbothpoints300and500includethepoint
400.Eventhoughthesignaliszeroatpoint400,youobtainanonzeroCWTcoefficientatthatscale.TheCWTcoefficientis
nonzerobecausethesupportofthewavelethasbecomesufficientlylargeatthatscaletoallowsignalvalues100points
aboveandbelowtoaffecttheCWTcoefficient.Youcanconfirmthisbyentering:
plot(CWTcoeffs(80,:));
gridon;
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
15/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Intheprecedingexample,theCWTcoefficientsbecamelargeinthevicinityofanabruptchangeinthesignal.Thisability
todetectdiscontinuitiesisastrengthofthewavelettransform.TheprecedingexamplealsodemonstratedthattheCWT
coefficientslocalizethediscontinuitybestatsmallscales.Atsmallscales,thesmallsupportofthewaveletensuresthatthe
singularityonlyaffectsasmallsetofwaveletcoefficients.
Todemonstratewhythewavelettransformissoadeptatdetectingabruptchangesinthesignal,considerashifted
Heaviside,orunitstepsignal.
x=[zeros(500,1);ones(500,1)];
CWTcoeffs=cwt(x,1:64,'haar','plot');colormapjet;
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
16/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Similartotheshiftedimpulseexample,theabrupttransitionintheshiftedstepfunctionresultsinlargeCWTcoefficientsat
thediscontinuity.Thefollowingfigureillustrateswhythisoccurs.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
17/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Intheprecedingfigure,theredfunctionistheshiftedunitstepfunction.TheblackfunctionslabeledA,B,andCdepictHaar
waveletsatthesamescalebutdifferentpositions.YoucanseethattheCWTcoefficientsaroundpositionAarezero.The
signaliszerointhatneighborhoodandthereforethewavelettransformisalsozerobecauseanywaveletintegratesto
zero.
NotetheHaarwaveletcenteredaroundpositionB.ThenegativepartoftheHaarwaveletoverlapswitharegionofthestep
functionthatisequalto1.TheCWTcoefficientsarenegativebecausetheproductoftheHaarwaveletandtheunitstepis
anegativeconstant.Integratingoverthatareayieldsanegativenumber.
NotetheHaarwaveletcenteredaroundpositionC.HeretheCWTcoefficientsarezero.Thestepfunctionisequaltoone.
Theproductofthewaveletwiththestepfunctionisequaltothewavelet.Integratinganywaveletoveritssupportiszero.
Thisisthezeromomentpropertyofwavelets.
AtpositionB,theHaarwavelethasalreadyshiftedintothenonzeroportionofthestepfunctionby1/2ofitssupport.As
soonasthesupportofthewaveletintersectswiththeunityportionofthestepfunction,theCWTcoefficientsarenonzero.In
fact,thesituationillustratedinthepreviousfigurecoincideswiththeCWTcoefficientsachievingtheirlargestabsolute
value.Thisisbecausetheentirenegativedeflectionofthewaveletoscillationoverlapswiththeunityportionoftheunit
stepwhilenoneofthepositivedeflectionofthewaveletdoes.Oncethewaveletshiftstothepointthatthepositive
deflectionoverlapswiththeunitstep,therewillbesomepositivecontributiontotheintegral.Thewaveletcoefficientsare
stillnegative(thenegativeportionoftheintegralislargerinarea),buttheyaresmallerinabsolutevaluethanthose
obtainedatpositionB.
Thefollowingfigureillustratestwootherpositionswherethewaveletintersectstheunityportionoftheunitstep.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
18/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Inthetopfigure,thewavelethasjustbeguntooverlapwiththeunityportionoftheunitstep.Inthiscase,theCWT
coefficientsarenegative,butnotaslargeinabsolutevalueasthoseobtainedatpositionB.Inthebottomfigure,the
wavelethasshiftedpastpositionBandthepositivedeflectionofthewaveletbeginstocontributetotheintegral.TheCWT
coefficientsarestillnegative,butnotaslargeinabsolutevalueasthoseobtainedatpositionB.
Youcannowvisualizehowthewavelettransformisabletodetectdiscontinuities.Youcanalsovisualizeinthissimple
exampleexactlywhytheCWTcoefficientsarenegativeintheCWToftheshiftedunitstepusingtheHaarwavelet.Note
thatthisbehaviordiffersforotherwavelets.
x=[zeros(500,1);ones(500,1)];
CWTcoeffs=cwt(x,1:64,'haar','plot');colormapjet;
%plotafewscalesforvisualization
subplot(311);
plot(CWTcoeffs(5,:));title('Scale5');
subplot(312);
plot(CWTcoeffs(10,:));title('Scale10');
subplot(313);
plot(CWTcoeffs(50,:));title('Scale50');
NextconsiderhowtheCWTrepresentssmoothsignals.Becausesinusoidaloscillationsareacommonphenomenon,this
sectionexamineshowsinusoidaloscillationsinthesignalaffecttheCWTcoefficients.Tobegin,considerthesym4wavelet
ataspecificscalesuperimposedonasinewave.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
19/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
RecallthattheCWTcoefficientsareobtainedbycomputingtheproductofthesignalwiththeshiftedandscaledanalyzing
waveletandintegratingtheresult.Thefollowingfigureshowstheproductofthewaveletandthesinusoidfromthe
precedingfigure.
YoucanseethatintegratingoverthisproductproducesapositiveCWTcoefficient.Thatresultsbecausetheoscillationin
thewaveletapproximatelymatchesaperiodofthesinewave.Thewaveletisinphasewiththesinewave.Thenegative
deflectionsofthewaveletapproximatelymatchthenegativedeflectionsofthesinewave.Thesameistrueofthepositive
deflectionsofboththewaveletandsinusoid.
Thefollowingfigureshiftsthewavelet1/2oftheperiodofthesinewave.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
20/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Examinetheproductoftheshiftedwaveletandthesinusoid.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
21/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
YoucanseethatintegratingoverthisproductproducesanegativeCWTcoefficient.Thatresultsbecausethewaveletis1/2
cycleoutofphasewiththesinewave.Thenegativedeflectionsofthewaveletapproximatelymatchthepositivedeflections
ofthesinewave.Thepositivedeflectionsofthewaveletapproximatelymatchthenegativedeflectionsofthesinusoid.
Finally,shiftthewaveletapproximatelyonequartercycleofthesinewave.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
22/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Thefollowingfigureshowstheproductoftheshiftedwaveletandthesinusoid.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
23/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
IntegratingoverthisproductproducesaCWTcoefficientmuchsmallerinabsolutevaluethaneitherofthetwoprevious
examples.Thatresultsbecausethenegativedeflectionofthewaveletapproximatelyalignswithapositivedeflectionofthe
sinewave.Also,themainpositivedeflectionofthewaveletapproximatelyalignswithapositivedeflectionofthesinewave.
Theresultingproductlooksmuchmorelikeawaveletthantheothertwoproducts.Ifitlookedexactlylikeawavelet,the
integralwouldbezero.
Atscaleswheretheoscillationinthewaveletoccursoneitheramuchlargerorsmallerscalethantheperiodofthesine
wave,youobtainCWTcoefficientsnearzero.Thefollowingfigureillustratesthecasewherethewaveletoscillatesona
muchsmallerscalethanthesinusoid.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
24/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Theproductshowninthebottompanecloselyresemblestheanalyzingwavelet.IntegratingthisproductresultsinaCWT
coefficientnearzero.
Thefollowingexampleconstructsa60HzsinewaveandobtainstheCWTusingthesym8wavelet.
t=linspace(0,1,1000);
x=cos(2*pi*60*t);
CWTcoeffs=cwt(x,1:64,'sym8','plot');colormapjet;
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
25/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
NotethattheCWTcoefficientsarelargeinabsolutevaluearoundscales9to21.Youcanfindthepseudofrequencies
correspondingtothesescalesusingthecommand:
freq=scal2frq(9:21,'sym8',1/1000);
NotethattheCWTcoefficientsarelargeatscalesnearthefrequencyofthesinewave.Youcanclearlyseethesinusoidal
patternintheCWTcoefficientsatthesescaleswiththefollowingcode.
surf(CWTcoeffs);colormapjet;
shading('interp');view(60,12);
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
26/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Thefinalexampleconstructsasignalconsistingofbothabrupttransitionsandsmoothoscillations.Thesignalisa4Hz
sinusoidwithtwointroduceddiscontinuities.
N=1024;
t=linspace(0,1,1024);
x=4*sin(4*pi*t);
x=xsign(t.3)sign(.72t);
plot(t,x);xlabel('t');ylabel('x');
gridon;
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
27/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
Notethediscontinuitiesneart=0.3andt=0.7.
ObtainandplottheCWTusingthesym4wavelet.
CWTcoeffs=cwt(x,1:180,'sym4');
imagesc(t,1:180,abs(CWTcoeffs));
colormapjet;axisxy;
xlabel('t');ylabel('Scales');
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
28/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
NotethattheCWTdetectsboththeabrupttransitionsandoscillationsinthesignal.TheabrupttransitionsaffecttheCWT
coefficientsatallscalesandclearlyseparatethemselvesfromsmoothersignalfeaturesatsmallscales.Ontheotherhand,
themaximaandminimaofthe2HzsinusoidareevidentintheCWTcoefficientsatlargescalesandnotapparentatsmall
scales.
ThefollowinggeneralprinciplesareimportanttokeepinmindwheninterpretingCWTcoefficients.
ConeofinfluenceDependingonthescale,theCWTcoefficientatapointcanbeaffectedbysignalvaluesatpoints
farremoved.Youhavetotakeintoaccountthesupportofthewaveletatspecificscales.Useconofinftodeterminethe
coneofinfluence.Notallwaveletsareequalintheirsupport.Forexample,theHaarwavelethassmallersupportatall
scalesthanthesym4wavelet.
DetectingabrupttransitionsWaveletsareveryusefulfordetectingabruptchangesinasignal.Abruptchangesina
signalproducerelativelylargewaveletcoefficients(inabsolutevalue)centeredaroundthediscontinuityatallscales.
Becauseofthesupportofthewavelet,thesetofCWTcoefficientsaffectedbythesingularityincreaseswithincreasing
scale.Recallthisisthedefinitionoftheconeofinfluence.Themostpreciselocalizationofthediscontinuitybasedon
theCWTcoefficientsisobtainedatthesmallestscales.
DetectingsmoothsignalfeaturesSmoothsignalfeaturesproducerelativelylargewaveletcoefficientsatscales
wheretheoscillationinthewaveletcorrelatesbestwiththesignalfeature.Forsinusoidaloscillations,theCWT
coefficientsdisplayanoscillatorypatternatscaleswheretheoscillationinthewaveletapproximatestheperiodofthe
sinewave.
RedundancyintheContinuousWaveletTransform
Anysignalprocessingperformedonacomputerusingrealworlddatamustbeperformedonadiscretesignalthatis,on
asignalthathasbeenmeasuredatdiscretetime.Sowhatexactlyis"continuous"abouttheCWT?
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
29/30
8/28/2015
ContinuousWaveletTransformMATLAB&Simulink
What's"continuous"abouttheCWT,andwhatdistinguishesitfromthediscretewavelettransform(tobediscussedinthe
followingsection),isthesetofscalesandpositionsatwhichitoperates.
Unlikethediscretewavelettransform,theCWTcanoperateateveryscale,fromthatoftheoriginalsignaluptosome
maximumscalethatyoudeterminebytradingoffyourneedfordetailedanalysiswithavailablecomputationalhorsepower.
TheCWTisalsocontinuousintermsofshifting:duringcomputation,theanalyzingwaveletisshiftedsmoothlyoverthefull
domainoftheanalyzedfunction.
http://www.mathworks.com/help/wavelet/gs/continuouswavelettransform.html
30/30