用MATLAB运行代码后总显示 Error using Untitled (line 2) Not enough input arguments.下面是我的源程序function dist = dtw(t,r)n = size(t,1);m = size(r,1);% 帧匹配距离矩阵d = zeros(n,m);for i = 1:nfor j = 1:md(i,j) = sum((t(i,:)-r(
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/16 09:00:17
用MATLAB运行代码后总显示 Error using Untitled (line 2) Not enough input arguments.下面是我的源程序function dist = dtw(t,r)n = size(t,1);m = size(r,1);% 帧匹配距离矩阵d = zeros(n,m);for i = 1:nfor j = 1:md(i,j) = sum((t(i,:)-r(
用MATLAB运行代码后总显示 Error using Untitled (line 2) Not enough input arguments.
下面是我的源程序
function dist = dtw(t,r)
n = size(t,1);
m = size(r,1);
% 帧匹配距离矩阵
d = zeros(n,m);
for i = 1:n
for j = 1:m
d(i,j) = sum((t(i,:)-r(j,:)).^2);
end
end
% 累积距离矩阵
D = ones(n,m) * realmax;
D(1,1) = d(1,1);
% 动态规划
for i = 2:n
for j = 1:m
D1 = D(i-1,j);
if j>1
D2 = D(i-1,j-1);
else
D2 = realmax;
end
if j>2
D3 = D(i-1,j-2);
else
D3 = realmax;
end
D(i,j) = d(i,j) + min([D1,D2,D3]);
end
end
dist = D(n,m);
disp('正在计算参考模板的参数...')
for i=1:5
fname = sprintf('E:\\MATLAB6p5\\work\\dtw_sj\\%da.wav',i);
x=fname;
[x1 x2] = vad(x);
m = mfcc(x);
m = m(x1-2:x2-2,:);
ref(i).mfcc = m;
% soundview(x);
end
disp('正在计算测试模板的参数...')
for i=1:1
fname = sprintf('E:\\MATLAB6p5\\work\\dtw_sj\\%db.wav',i);
x=fname;
[x1 x2] = vad(x);
m = mfcc(x);
m = m(x1-2:x2-2,:);
test(i).mfcc = m;
end
disp('正在进行模板匹配...')
dist = zeros(1,5);
for i=1:1
for j=1:5
dist(i,j) = dtw(test(i).mfcc,ref(j).mfcc);
end
end
disp('正在计算匹配结果...')
for i=1:1
[d,j] = min(dist(i,:));
fprintf('测试模板 %d 的识别结果为:%d\n',i,j);
end
用MATLAB运行代码后总显示 Error using Untitled (line 2) Not enough input arguments.下面是我的源程序function dist = dtw(t,r)n = size(t,1);m = size(r,1);% 帧匹配距离矩阵d = zeros(n,m);for i = 1:nfor j = 1:md(i,j) = sum((t(i,:)-r(
你运行函数的时候加参数了么.