
194 CHAPTER 10. PROJECT 1: GUITAR SPECIAL EFFECTS
Listing 10.3: A MATLAB IIR comb filter example.
1 % Method using the filter command
3 R=round ( R ); % ensure R is an integer before proceeding
A=zeros(1 ,R+1) ; % correct length of vector A
5 A (1)=1; A ( R+1)=−alpha ;
% A vector is now ready to use filter command
7 B=zeros (1 ,R+1) ; % correct length of vector B
B ( R+1)=1; % use "B =1;" for other IIR version
9 % B vector is now ready to use filter command
y=filter( B , A , x );
Lines 4 and 5 ensure the A coefficient vector has the proper length and values (take note
of the sign needed for alpha). Lines 7 and 8 set up the B vector properly. If you would