MATLAB 中的转换信号



我想实现一个系统来识别0-9之间的数字。我有一个模板集和一个 0-9 之间的数字录制音频信号的测试集。我必须在所有音频文件之间进行交叉关联,以找到它们之间的最佳相似性。之后,我应该对每个信号进行时移以使其同步,以便将其与其他信号进行比较以获得最佳结果。我不知道如何实现时移。

MaxSize=[0,0];
for i=1:9
    TempSize=size(temp{i});
    TestSize=size(test{i});
    if(TempSize(1)>MaxSize(1))
        MaxSize(1)=TempSize(1);
    end
    if(TestSize(1)>MaxSize(1))
        MaxSize(1)=TestSize(1); 
    end
end
for j=1:9
    TsSize=(MaxSize-size( temp{j}));
    TpSize=(MaxSize-size( test{j}));
   temp{j}(end+TsSize)=0;
    test{j}(end+TpSize)=0;

end
%------------ Euclidean distance-----
sum=0;
 index=zeros(1,9); 
 Distance=zeros(9,9);
for m =1:9
   MinDistance=10000;
    for n=1:9
      Distance(m,n)= norm(test{m}-temp{n},2);
     if (Distance< MinDistance)
        index(m,n)=n;
          MinDistance=Distance;   
     end 
    end
   if(index(m)==m)
          sum=sum+1;
    end    
end
%--------------------------------------------------------------
TimeDiff=zeros(9,9);
for l=1:9
    for k=1:9
      [c,lag]=xcorr(test{l},temp{k});
      TimeDiff(l,k)=max(abs(c));
    end
end
%euclidean distance
 index=zeros(1,10); 
 Distance=zeros(10,10);
 for m =1:10
   MinDistance=10000;
    for n=1:10
      Distance(m,n)= norm(test{m}-temp{n},2);
     if (Distance < MinDistance)
        index(m,n)=n;
         MinDistance=Distance;   
     end 
    end
end
TimeDiff=zeros(10,10);
euclidean =zeros(10,10);
for l=1:10
    for i=1:10
      [c,lag]=xcorr(test{l},temp{i});
      [~,I]= max(abs(c));  
      shifted= circshift(test{1},I);
      euclidean(l,k)=norm(temp{l}-shifted,2);
    end
end
%.................................................
Index=0;
for i=1:10
    Min=1000000;
    for j=1:10
      if( euclidean(i,j)<Min ) 
          Min=euclidean(i,j);
          index=j;
      end 
    end
end

然后交叉关联信号。

最新更新