function [ymodify y2modify r] = draw_dtw(y1,pla1,p,y2,pla2,q) l=length(p); i=1; j=1; la=pla1(p(1)); lb=pla2(q(1)); while p(i+1)==p(1) i=i+1; end while q(j+1)==q(1) j=j+1; end point=max(i,j)+1; outputx=[]; outputy=[]; while (point<=l) tp=1; tq=1; while (point+1<=l && ((p(point+1)==p(point)) || (q(point+1)==q(point)))) point=point+1; end if point<=l laold=la; lbold=lb; la=pla1(p(point)); lb=pla2(q(point)); %intvb=(la-laold)/(lb-lbold); intvb=(lb-lbold)/(la-laold)/10; xx=pla1(p(i)):intvb:pla1(p(point)); yy=y2(pla2(q(j)):pla2(q(point))); x1=xx(1):(xx(length(xx))-xx(1))/(length(yy)-1):xx(length(xx)); if length(xx)<=1 y=yy(end); else y = griddedInterpolant(x1,yy,'spline'); y = y(xx); % y = interp1(x1,yy,xx,'spline'); % 12-19-2017 Modified by Giulia Da Poian % replaced interp1 with griddedInterpolant for speed end % plot(xx,y,'k'); outputx=[outputx,xx]; outputy=[outputy,y]; i=point; j=point; end point=point+1; end % outputxx=unique(outputx); j=1; i=1; while i<=length(outputx)-1 while i