gusucode.com > 用matlab仿真0到9十个数字的语音识别源码程序 > Speech-Recogenition/readlab.m

    function [qs,zz,num]=readlab(file)

fid=fopen(file,'r','b');
if fid < 0
   error(sprintf('Cannot read from file %s',file));
end
F= fread(fid,'uchar');
j=1;
for i=1:4
        b=0;
    while F(j) ~= 32
        aa=F(j);
        j=j+1;
        aa=aa-48;
        b=b*10+aa;
    end
    j=j+1;
    qs(i)=b;
    b=0;
    while F(j) ~= 32
        aa=F(j);
        j=j+1;
        aa=aa-48;
        b=b*10+aa;
    end
    j=j+1;
    zz(i)=b;
    b=0;
    while F(j) ~= 10
        aa=F(j);
        j=j+1;
        b=b+aa;
    end
    num(i)=b;
    j=j+1;
end
for i=1:4
switch num(i)
          case {236}
            num(i)=5;
         case {422}
            num(i)=7;
          case {195}
            num(i)=8;
            case {330}
            num(i)=6;
         case {523}
            num(i)=2;
          case {322}
            num(i)=3;
            case {220}
            num(i)=4;
         case {331}
            num(i)=9;
          case {424}
            num(i)=0;
            case {329}
            num(i)=1;
          otherwise
            num(i)=num(i);
end
        
end