## A noisy sine wave as query
## A cosine is for template; sin and cos are offset by 25 samples
idx<-seq(0,6.28,len=100);
query<-sin(idx)+runif(100)/10;
template<-cos(idx)
dtw(query,template,step=asymmetricP1)->alignment;
## Equivalent to plot(alignment,xts=query,yts=template,type="two");
dtwPlotTwoWay(alignment,xts=query,yts=template);
## Beware of the template's y axis, may be confusing
plot(alignment,xts=query,yts=template,offset=-2,type="two");
legend("topright",c("Query","Template"), pch=21, col=1:6)
Run the code above in your browser using DataLab