Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
SYSTEM
DIAGRAM
i) = pi/6
Hf(z) =1- 2cos(pi/6)z-1 +z-2
ii) = pi/3
Hf(z) =1- 2cos(pi/3)z-1 +z-2
ii) = pi/2
Hf(z) =1- 2cos(pi/2)z-1 +z-2
Hf(z) =1 + z-2
%%Matlab commands for the magnitude response for the three values of
w = -pi:2*pi/200:pi;
theta1=pi/6;
theta2=pi/3;
theta3=pi/2;
H1 =1-2*(cos(theta1) )*exp(-j*w)+ exp(-j*2*w);
H2 =1-2*(cos(theta2) )*exp(-j*w)+ exp(-j*2*w);
H3 =1-2*(cos(theta3) )*exp(-j*w)+ exp(-j*2*w);
subplot(311)
plot(w,abs(H1))
grid
ylabel('Magnitude')
xlabel('(rad)')
title('pi/6')
subplot(312)
plot(w,abs(H2))
grid
ylabel('Magnitude')
xlabel('(rad)')
title('pi/3')
subplot(313)
plot(w,abs(H3))
grid
ylabel('Magnitude')
xlabel('(rad)')
title('pi/2')
Explain how the value of affects the magnitude of the filters frequency
response
ans =
-1.3254
Matlab function FIRfilter(x) that implements the filter Hf (z) with the
measured value of and outputs the filtered signal
Version1
function [ F ] = FIRfilter(x,theta)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
a=-2*cos(theta);
f=[1,a,1];
F=conv(x,f);
Version2
function [ F ] = FIRfilter(x)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
a=-2*cos( -1.3254);
f=[1,a,1];
F=conv(x,f);
Filtering using version 1
%%Matlab commands
theta= w(Imax)
F=Firfilter(nspeech1,theta);
sound(f)
plot of the magnitude of the DTFT for 1001 samples of filtered npeech1
sample3=F(100:1100);
[X,w]=DTFT(sample3,0);
figure(2)
plot(w,abs(X));
ylabel('Magnitude')
xlabel('(rad)')
title('Magnitude response of Filtered signal')
We have,
HI(z) = (1-r)/( 1- 2cos.rz-1 +r2z-2)
(Difference equation)
the plot of the magnitude of the frequency response for each value of r.
Matlab Commands
clear all
close all
clc
r1= 0.99;
r2 = 0.9;
r3 = 0.7;
theta=pi/3;
w = -pi:2*pi/200:pi;
plot of the magnitude of the DTFT computed from 1001 samples of the
PCM
Matlab Commands
sample1=pcm(100:1100);
[X,w]=DTFT(sample1,0);
plot(w,abs(X));
ylabel('Magnitude')
xlabel('(rad)')
[Xmax,Imax]=max(abs(X));
theta= w(Imax);
theta =-2.4728;
figure(2)
plot(w,abs(X));
ylabel('Magnitude')
xlabel('(rad)')
plot of the magnitude of the DTFT for ! in the range [_ 0.02, _ + 0.02].
figure(2)
plot(w,abs(X));
ylabel('Magnitude')
xlabel('(rad)')
xlim([theta-0.02 theta+0.02])
title('DTFT in the range of theta 0.02, theta+ 0.02')
Calculation of theta
y(n)+ ary(n-1)+ r2y(n-2) = (1-r)x(n)
(Difference equation)
time domain plot of the signal for 101 points of filtered PCM
y=filtered_pcm;
sample=y(100:200);
t=100:200;
figure(1)
plot(t,sample)
title('101 sample values of fitered_pcm')
plot of the magnitude of the DTFT computed from 1001 samples of the
filtered PCM
sample1=y(100:1100);
[X,w]=DTFT(sample1,0);
figure(2)
plot(w,abs(X));
ylabel('Magnitude')
xlabel('(rad)')
title('Magnitude spectrum of fittered_pcm')
plots of the magnitude response for the two filters (not in decibels).
Matlab commands
[X1,w1]=DTFT(f1,512);
[X2,w2]=DTFT(f2,512);
figure(1)
plot(w1,20*log10(abs(X1))); %to plot the graph
title('fir with N=21')
figure(2)
plot(w2,20*log10(abs(X2)));
title('fir with N=101')%to plot the graph
Filt_1=conv(f1,x);
Filt_2=conv(f2,x);
sound(Filt_1)
sound(Filt_2)