dtw example from MatLab Documentation doesn't not work
18 次查看(过去 30 天)
显示 更早的评论
When I run the sample for speech recognition using dtw at https://www.mathworks.com/help/signal/ref/dtw.html#d120e38502 in the browser version of MatLab it works but shows an error. However, when I run it in MatLab on my computer, the line with "[d,i1,i2] = dtw(a1,a2);" throws a code stopping error saying "Too many output arguments." This is an example from the MatLab documentation so I would figure that it should work especially since it does work in the online version. In order to learn how to use this function properly, I need for the example to work. The full code from the example is shown below. The line that throws the error is shown in BOLD. Can someone help me with this?
load mtlb
a1 = mtlb(round(0.15*Fs):round(0.25*Fs)); a2 = mtlb(round(0.37*Fs):round(0.45*Fs));
subplot(2,1,1) plot((0:numel(a1)-1)/Fs+0.15,a1) title('a_1') subplot(2,1,2) plot((0:numel(a2)-1)/Fs+0.37,a2) title('a_2') xlabel('Time (seconds)')
[d,i1,i2] = dtw(a1,a2);
a1w = a1(i1); a2w = a2(i2);
t = (0:numel(i1)-1)/Fs; duration = t(end) duration = 0.1297 subplot(2,1,1) plot(t,a1w) title('a_1, Warped') subplot(2,1,2) plot(t,a2w) title('a_2, Warped') xlabel('Time (seconds)')
load(fullfile(matlabroot,'examples','signal','strong.mat'))
% To hear, type soundsc(her,fs), pause(2), soundsc(him,fs)
dtw(her,him,'absolute'); legend('her','him')
[d,iher,ihim] = dtw(her,him,'absolute'); duration = numel(iher)/fs duration = 0.8394 % To hear, type soundsc(her(iher),fs), pause(2), soundsc(him(ihim),fs)
2 个评论
Adam
2018-9-28
编辑:Adam
2018-9-28
What do you get when you type
which -all dtw
on command line?
I suspect you have another function called dtw.
Also be careful in general of using online documentation if you are not using the latest version of the software. In this case the syntax of dtw is unchanged from R2018a so it isn't a problem, but the online documentation and examples are always for the latest release, R2018b in this case.
采纳的回答
Sean de Wolski
2018-9-28
The second occurrence is the one you want. Rename the first file to something else.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!