dtw example from MatLab Documentation doesn't not work

조회 수: 18 (최근 30일)
Jamie Dixson
Jamie Dixson 2018년 9월 28일
답변: Sean de Wolski 2018년 9월 28일
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
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.
Jamie Dixson
Jamie Dixson 2018년 9월 28일
편집: Jamie Dixson 2018년 9월 28일
It does appear that I have two. This is the result I get:
>> which -all dtw C:\Users\jamie\OneDrive\Documents\MATLAB\dtw.m C:\Program Files\MATLAB\R2018b\toolbox\signal\signal\dtw.m % Shadowed
I am new to MatLab. How can I get rid of the second occurrence?

댓글을 달려면 로그인하십시오.

채택된 답변

Sean de Wolski
Sean de Wolski 2018년 9월 28일
The second occurrence is the one you want. Rename the first file to something else.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by