function M = Simtrix(A,B) % This script displays a similarity matrix and (optionally) a dynamic time % warping path. The lines marked with an asterix (*) are the work of Dan % Ellis http://www.ee.columbia.edu/~dpwe/. Please visit his website for % in depth tutorials on MIDI and DTW in Matlab as well as the DTW script % "dp2.m" that is needed if you wish to add this to the graph (uncomment the % last lines accordingly). % % by Robert Macrae 2009. sizeA = size(A); sizeB = size(B); dim1 = min(sizeA(1),sizeB(1)); dim2 = min(sizeA(2),sizeB(2)); A=A(1:dim1,1:dim2); B=B(1:dim1,1:dim2); figure('Name','Dynamic Time Warp','Position',[100,1000,500,500]); colormap(hot); subplot('Position',[0.05,0.3,0.2,0.65]); imagesc(A); set(gca,'YDir','normal'); set(gca,'XDir','reverse'); subplot('position',[0.3,0.05,0.65,0.2]); xlabel('x'); ylabel('|Error|'); imagesc(B'); set(gca,'YDir','normal'); subplot('Position',[0.3,0.3,0.65,0.65]); A = A'; B = B'; EA = sqrt(sum(A.^2)); % (*) EB = sqrt(sum(B.^2)); % (*) M = (A'*B)./(EA'*EB); % (*) imagesc(M); set(gca,'YDir','normal'); % hold on; % [p,q,C]=dp2(M); % plot(q,p,'r'); % hold off;