31 ●5 How to use Dynamic Time Warping (DTW) algorithm in matlab?

3 views (last 30 days)
I am new in matlab. I've been browsing for few hours and I'm still getting errors. I want to know how to use dtw algorithm in matlab and I want to know the output of these two audio files using dtw algorithm. this is my code:
fftNyol = fft(audioread('C:\Users\handy\Documents\MATLAB\my_recording_1.wav'));
fftFajar = fft(audioread('C:\Users\handy\Documents\MATLAB\fajar.wav'));
dist = dtw(fftNyol,fftFajar);
this is error message from matlab:
Error using zeros
Requested 137281x87361 (89.4GB) array exceeds maximum array size preference. Creation of arrays greater than this limit
may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more
information.
Error in dtw (line 27)
D=zeros(ns+1,nt+1)+Inf; % cache matrix
Error in test (line 15)
dist = dtw(fftNyol,fftFajar);

Accepted Answer

Walter Roberson
Walter Roberson on 26 Feb 2018
You are not using Mathworks dtw() from the signal processing toolbox. Mathworks dtw() has comments at line 27.
  7 Comments
Walter Roberson
Walter Roberson on 26 Feb 2018
I think you are past the original problem, whatever it is.
Now you have the problem that your wav files are different lengths (different number of samples.)
Wu Sunner
Wu Sunner on 1 Jul 2019
Hi~~
you just transportation "fftNyol" & "fftFajar"
ex:
vec1 = [1 2 3 4 5];
vec11 = vec1';
you can try to do:
fftNyol_tr = fftNyol';
fftFajar_tr = fftFajar';
dist = dtw(fftNyol_tr, fftFajar_tr);
Because :
dist = dtw( x , y ) stretches two vectors, x and y , onto a common set of instants such that dist , the sum of the Euclidean distances between corresponding points, is smallest. To stretch the inputs, dtw repeats each element of x and y as many times as necessary. If x and yare matrices, then dist stretches them by repeating their columns. In that case, x and y must have the same number of rows.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!