function plot_a_lsf(a,f); % Syntax: plot_a_lsf(a,f) % % Function for plotting of LPC and LSF. % a is the vector of LPC coefficients [1 a1 ... aP] - size P+1 % f is the vector of Line Spectrum Frequencies (LSF) - size P % Two plots are produced % - normalized module of LPC spectrum with LSFs belonging % to polynomial P (green) and Q (red) % - roots of P (green) and of Q (red) % a and f are COLUMN vectors. M=length(a)-1; if length(f) ~= M error ('The length of vector a must be the length of f plus one'); end a=[a; 0]; p=a-a(M+2:-1:1); q=a+a(M+2:-1:1); rp=roots(p); rq=roots(q); figure(1); % roots in z-plane polar(angle(rp), abs(rp), 'og'); % P hold on polar(angle(rq), abs(rq), 'or'); % Q hold off title ('P - green, Q - red'); figure(2); % LPC spec + frequencies. hold off; if (M/2)==floor(M/2), % M even - P and Q have the same no. of freq. % Q begins. fq=f(1:2:M-1); % Q will have the 1st freq from f fp=f(2:2:M); % P will have the 2nd noP=M/2; noQ=M/2; % numbers else % M odd - Q will have 1 more freq. than P fq=f(1:2:M); % Q will have the 1st freq from f fp=f(2:2:M-1); % P has less noP=(M+1)/2-1; noQ=(M+1)/2; end f=(0:511)/1024; H=abs(freqz(1,a,512)); maxH=max(H); plot(f,H,'y'); hold on; % spec in yellow %cannot make colors - stupisd !stem(fp,maxH*ones(noP,1),'g'); % P in green %stem(fq,maxH*ones(noQ,1),'r'); % Q in red for i=1:noP, plot([fp fp],[0,maxH],'g'); end for i=1:noQ, plot([fq fq],[0,maxH],'r'); end hold off title ('LPC spec. - yellow, P - green. Q - red');