SAX符号化序列范例源码--------------------timeseries2symbol.m:--------------------Thisfunctiontakesinatimeseriesandconvertittostring(s).Therearetwooptions:1.ConverttheentiretimeseriestoONEstring2.Useslidingwindows,extractthesubsequencesandconvertthesesubsequencestostringsForthefirstoption,simplyenterthelengthofthetimeseriesas"N"ex.Wehaveatimeseriesoflength32andwewanttoconvertittoa8-symbolstring,withalphabetsize3:timeseries2symbol(data,32,8,3)Forthesecondoption,enterthedesiredslidingwindowlengthas"N"ex.Wehaveatimeseriesoflength32andwewanttoextractsubsequencesoflength16usingslidingwindows,andconvertthesubsequencesto8-symbolstrings,withalphabetsize3:timeseries2symbol(data,16,8,3)Input:dataistherawtimeseries.Nisthelengthofslidingwindow(usethelengthoftherawtimeseriesinsteadifyoudon'twanttohaveslidingwindows)nisthenumberofsymbolsinthelowdimensionalapproximationofthesubsequence.alphabet_sizeisthenumberofdiscretesymbols.2<=alphabet_size<=10,althoughalphabet_size=2isa special"useless"case.Output:symbolic_data:matrixofsymbolicdata(no-repetition).Ifconsecutivesubsequenceshavethesamestring,thenonlythefirstoccurrenceisrecorded,withapointertoitslocationstoredin"pointers"pointers:locationofthefirstoccurrencesofthestringsN/nmustbeaninteger,otherwisetheprogramwillgiveawarning,andabort.Thevariable"win_size"isassignedtoN/n,thisisthenumberofdatapointsontherawtimeseriesthatwillbemappedtoasinglesymbol,andcanbeimaginedasthe"compressionrate".Thesymbolicdataisreturnedin"symbolic_data",withpointerstoth
1