0

我得到了声门脉冲的代码,当我尝试通过初始化参数来运行它时,我得到了一个脉冲。但是,当我尝试在信号上实现它时,我无法获得输出。我收到错误消息:

下标分配尺寸不匹配

fs= 11025;
f0= 190;
N1=12;
N2=17;
T=1/f0;     %period in seconds
pulselength=floor(T*fs);    %length of one period of pulse
%select N1 and N2 for duty cycle
N2=floor(pulselength*N2);
N1=floor(N1*N2);
gn=zeros(1,N2);
%calculate pulse samples
for n=1:N1-1
    gn(n)=0.5*(1-cos(pi*(n-1)/N1));
end
for n=N1:N2
    gn(n)=cos(pi*(n-N1)/(N2-N1)/2);
end
gn=[gn zeros(1,(pulselength-N2))];
plot(gn);

请仔细阅读代码并帮助我哪里出错了。

4

1 回答 1

1

我假设您的代码段来自http://www.mattmontag.com/projects/speech/rosenberg.m。将N1和设置N2为 0 到 1 之间的值。

从帮助到rosenberg.m

N2 is duty cycle of the pulse, from 0 to 1.
N1 is the duration of the glottal opening as a fraction of the total pulse, from 0 to 1.

具有不同 N1 和 N2 值的 Rosenberg 脉冲

于 2016-11-13T00:48:12.183 回答