



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




%%%%%% sequence generation %%%%%%% M=10; n=0:20; x=(1.5).^n; x1=[zeros(1,2000) x];
x2=fliplr(x1); sequence=[x1 x2]; figure(1); subplot(221); stem(sequence); title('sequence graph before decimation') fft_of_sequence=abs(fft(sequence,8192)); x1=[0:1:8191]./(4096); figure(1); subplot(222); plot(x1,fft_of_sequence); title('frequency domain before decimation')
%%%%%%% Prefiltering for decimation %%%%%%%%%% cutoff=1/M; order=400; b=fir1(order,cutoff); % Calculating numirator of FIR filter with cutoff 1/M to avoide alising filtered_sequence=filter(b,1,sequence); % Appling FIR filter to the sequence figure(1); subplot(223); stem(filtered_sequence); title('Sequence graph after filter before decimation') fft_of_filtered_sequence=abs(fft(filtered_sequence,8192)); figure(1); subplot(224); plot(x1,fft_of_filtered_sequence); title('frequency domain after filter before decimation')
%%%%%%% Decimation by factor M %%%%%%%%% deci_sequence=filtered_sequence(1:M:length(filtered_sequence)); % pick sample after gap of M in filterd sequence figure(3); subplot(211); stem(deci_sequence); title('Sequence after filter and decimation') fft_of_deci_sequence=abs(fft(deci_sequence,8192)); figure(3); subplot(212); title('frequency after filter and decimation') plot(x1,fft_of_deci_sequence);
Upsampling (Interpolation):
subplot(311); plot(x1,fft_of_sequence); title('Fequency domain before interpolation')
%%%%%%%%%% Up sampling by a factor of L %%%%%%%%% L=2; interpol_sequence =zeros(1,L*(length(sequence))); % Creating zeros vector j = 1;
for i = 1:L:length(interpol_sequence) % adding zeros to the sequence interpol_sequence(1,i) = sequence(1,j); j=j+1; end figure(1); subplot(312),stem(interpol_sequence);title('Sequence after interpolation') fft_of_interpol_sequence = abs(fft(interpol_sequence,131072)); figure(2); subplot(312); plot(x1,fft_of_interpol_sequence);title('fequency domain after interpolation')
MATLAB COMMANDS: