0

I got a code for glottal pulse and when i tried to run that by initializing the parameters i get a single pulse. But, when i try to implement it on signal i could not get an output. I am getting error as:

Subscripted assignment dimension mismatch

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);

Please go through the code and help me where i am going wrong.

Matlab_Begineer
  • 7
  • 1
  • 2
  • 6
  • Do your own debugging! At minimum, run your code line-by-line, work out where the error occurs. (There's nothing obviously wrong with what you've posted, btw, other than the obligatory comments about vectorisation). – nkjt Apr 09 '14 at 13:26

1 Answers1

1

I assume that your snippet originates from http://www.mattmontag.com/projects/speech/rosenberg.m. Set N1 and N2 to values between 0 and 1.

From the help to 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.

Rosenberg pulse with different values for N1 and N2

kalleknast
  • 301
  • 2
  • 3
  • 10