注册 登录
编程论坛 Matlab

求助:代码生成要求在对变量 'm' 标注下标前对该变量进行完全定义。如何解决

偏爱与例外 发布于 2022-11-15 17:48, 4021 次点击
程序代码:
function m= goertzel_decode(y)
%goertzel_decodejia
%   此处显示详细说明
% 端点检测
tm=['1','2','3','A';'4','5','6','B';'7','8','9','C';'*','0','#','D'];   % DTMF信号代表的16个数
TNr=0;
N=205;
K=[18,20,22,24,31,34,38,42];
p=1;
q=1;
% 读取语音
% [y,Fs]=audioread(w);
% 预加重
u=0.95;
b=[1, -u];
a=1;
y=filter(b,a,y);

% 分帧
s=enframe(y,160,80);

% 短时平均幅值
avga=sum(abs(s),2);

% 短时过零率
s1 = s;
avgz=s1.*[zeros(size(s1,1),1),s1(:,1:end-1)];
avgz(avgz>=0)=0;
avgz(avgz<0)=1;
avgz=sum(avgz,2);

% 端点检测
MH=20;
ML=19;
ZS=40;
if length(avga)~=length(avgz)
    disp('errors')
end
a1=1;
a2=1;
b1=1;
b2=1;
c1=1;
c2=1;
while a1<length(avga)
    if avga(a1) >= MH % 浊音开始
        for a2=a1+1:length(avga)
            if avga(a2) < MH % 浊音结束
                for b1=a1-1:-1:c2+1
                    if avga(b1) <= ML
                        break % 精确浊音开始
                    end
                end
                for b2=a2+1:length(avga)
                    if avga(b2) <= ML
                        break % 精确浊音结束
                    end
                end
                for c1=b1-1:-1:c2+1
                    if avgz(c1) <= 3*ZS
                        break % 精确清辅音开始
                    end
                end
                for c2=b2+1:length(avgz)
                    if avgz(c2) <= 3*ZS
                        break % 精确清辅音结束
                    end
                end
                break
            end
        end
        % 输出一个语音段
      %  sprintf('%d,%d,%d,%d,%d,%d',c1,b1,a1,a2,b2,c2)
          s_start=1;
        s_end=(c2-1)*80;
        if s_end>900
            s_start=(c1-1)*80;
        end
    q=q+1;
        g=y(s_start+100:s_end+100);
         X=goertzel(g(1:N),K);            % 用Goertzel算法计算八点DFT样本     
           val = abs(X); % 列出八点DFT向量
               limit = 13;                 %   
 for s=5:8
     if val(s) > limit, break, end       % 查找列号   
 end     
for r=1:4         
 if val(r) > limit, break, end       % 查找行号   
end  
TNr=tm(r,s-4);
        a1=c2;
        p=p+1;
        m(p-1,1)=TNr;%  把新的数据追加到数组中。
    end
   a1=a1+1;
end
p=1;
end



代码生成要求在对变量 'm' 标注下标前对该变量进行完全定义。
0 回复
1