The objective of this topic is to perform Z-Transform in MATLAB and to understand the filter design using FDA tool.
What Is The Description:-
Z-transform 𝑋(𝑧) of any signal x[n] is define as:
The inverse Z-transform is denoted by:
In particular, for any LTI system, the system response (output
response) 𝑦[𝑛] can be determined by using the convolution integral such that 𝑦[𝑛]
= 𝑥[𝑛] ∗ ℎ[𝑛] where ℎ[𝑛] is impulse response of the system.
By applying the convolution property in z transform on both sides,
we have
𝑌(𝑧) = 𝑋(𝑧)𝐻(𝑧)
𝐻(𝑧) = 𝑌(𝑧) / 𝑋(𝑧)
where 𝑌(𝑧) and 𝐻(𝑧) are the z transform of 𝑦[𝑛] and ℎ[𝑛] respectively. 𝐻(𝑧) is also called
the system function or transfer function.
Z-transform in MALTAB:-
Let computes the z-transform of the symbolic expression:
Example:
and its Z-transform is
FDA TOOL:
The Filter Design and Analysis Tool (FDATool) is a powerful user interface for designing and analyzing filters. FDATool enables you to quickly design digital FIR or IIR filters by setting filter performance specifications, by importing filters from your MATLAB workspace, by directly specifying filter coefficients, or by adding, moving or deleting poles and zeros. FDATool also provides tools for analyzing filters, such as magnitude and phase response plots and pole-zero plots.
To open the Filter Design and Analysis Tool (FDATool), type
>> fdatool
The Filter Design and Analysis Tool opens with the Design Filter panel displayed.
Here are the Practice problem regarding this topic to understand :
1(A). Compute the inverse Z-transform of
the following Z-transform functions.
1(B). Compute the Z-transform of the
following functions. Plot it poles and zeros and then determine it ROCs.
2.Determine the partial fraction expansion of the
z-transform H(z) given by:
Draw
pole zero plot. Mention ROC and comment on causality and stability of the
system
3(A). Design a (Lowpass and Highpass)filter
using FDA Tool. Analyze all the following characteristic of respective filter
using Tool.
·
Magnitude and Phase responses
·
Impulse response
·
Step response
·
Pole-zero plot
3(B). Apply that filters on audio, analyze
and plot the signals.
01:
Part 1
x = (1-(5/9)*z^-1 + z^-2)/ (1-(9*z^-1)+ (4*z^-2)); % input expression
disp('Given
Z-Transform expression')
disp(x)
IZTrans = iztrans(x) ;
%inverse Z
Transform
disp('Inverse
Z-Transform')
disp(IZTrans)
Part 2
CODE:
syms n x
x = (-1/4)^n - (1/8)^n; %input function
ZTrans = ztrans(x) ;
%calulate z transform
disp('Z-Transform
of x[n] is ');
pretty(ZTrans) %display output
c=collect(ZTrans); %collects coefficients
[n,d]=numden(c); %extracts numerator and
denominator by forimg rational expression
num=sym2poly(n); %returns coefficients of numerator
den=sym2poly(d); %returns coefficients of
denominator
disp('System is
defined as ');
TFx=tf(num,den,1) %calculates transfer function
disp('Poles of the system
');
poles = pole(TFx) ; %poles
disp(poles)
disp('Zeros of the
system ');
zeros = zero(TFx) ; %zeros
disp(zeros)
abso = abs(poles); %takes absolute of the poles to
decide the ROC
%Since both sequences are
RHS, the ROCis outside the outermost pole
disp('Region of
Convergence is outside the circle with radius ');
ROC = max(abso); %Radius of ROC
disp(ROC)
zplane(num,den) %Show pole-zero plot
title ('Poles and
Zeros')
OUTPUT:
02:
CODE:
syms x z
x = (12*z^3)/((12*z^3)+
(5*z^2)-3*z -1); % input expression
disp('Given
Z-Transform expression')
pretty(x)
c=collect(x); %collects coefficients
[n,d]=numden(c); %extracts numerator and
denominator by forimg rational expression
num=sym2poly(n); %returns coefficients of numerator
den=sym2poly(d); %returns coefficients of
denominator
disp('System is
defined as ');
TFx=tf(num,den,1) %calculates transfer function
[R,P,K] = residuez(num,den);
disp('Partial
Fraction terms ');
disp(R)
disp('Value of k');
disp(K)
disp('Poles of the
system ');
disp(P)
disp('Zeros of the
system ');
zeros = zero(TFx) ; %zeros
disp(zeros)
abso = abs(poles); %takes absolute of the poles to
decide the ROC
disp('Region of
Convergence is outside the circle with radius ');
ROC = max(abso); %Radius of ROC
disp(ROC)
zplane(num,den) %Show pole-zero plot
title ('Poles and
Zeros')
OUTPUT:
Since all the poles are inside the unit circle, the system is stable and causal.
03:
Part 1 (a)
Low Pass Filter
SPECIFICATIONS:
RESPONSES:
MATLAB GENERATED CODE:
function Hd = mylow
%MYLOW Returns a
discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R)
9.4 and Signal Processing Toolbox 8.0.
% Generated on: 18-Apr-2020
21:44:31
% FIR least-squares Lowpass
filter designed using the FIRLS function.
% All frequency values are
in Hz.
Fs = 8000; % Sampling Frequency
N = 10;
% Order
Fpass = 1000; % Passband Frequency
Fstop = 1200; % Stopband Frequency
Wpass = 1; % Passband Weight
Wstop = 1; % Stopband Weight
% Calculate the
coefficients using the FIRLS function.
b
= firls(N, [0 Fpass Fstop Fs/2]/(Fs/2), [1 1 0 0], [Wpass Wstop]);
Hd = dfilt.dffir(b);
% [EOF]
Part 1(b)
High Pass Filter
SPECIFICATIONS:
RESPONSES:
MATLAB GENERATED CODE:
function Hd = MYHIGH
%MYHIGH Returns a
discrete-time filter object.
% MATLAB Code
% Generated by MATLAB(R)
9.4 and Signal Processing Toolbox 8.0.
% Generated on: 18-Apr-2020
22:01:26
% FIR least-squares
Highpass filter designed using the FIRLS function.
% All frequency values are
in Hz.
Fs = 8000; % Sampling Frequency
N = 10;
% Order
Fstop = 1500; % Stopband Frequency
Fpass = 1700; % Passband Frequency
Wstop = 1; % Stopband Weight
Wpass = 1; % Passband Weight
% Calculate the
coefficients using the FIRLS function.
b
= firls(N, [0 Fstop Fpass Fs/2]/(Fs/2), [0 0 1 1], [Wstop Wpass]);
Hd = dfilt.dffir(b);
% [EOF]
Part 2(a)
Applied Low Pass
Filter On Generated Audio
CODE:
rec = audiorecorder(8000,8,1); %create an
object for recording
record(rec,5); %record
for 5 seconds
data =getaudiodata(rec); %generate audio data
Fs =8000; %sampling
frequency
T = 1/Fs;
subplot(2,2,1)
plot(data)
axis ([0 40000 -0.2 0.2])
title('Original
Signal in Time Domain')
xlabel('Time')
ylabel('Amplitude')
subplot(2,2,2)
ty = fft(data);
f =
(0:length(ty)-1)*Fs/length(ty);
plot(f,ty)
title('Original
Signal in Frequency Domain')
xlabel('Frequency')
ylabel('Magnitude')
subplot(2,2,3)
Filtered
=filter(Hdowy,data); %Hdlowy is
the Low Pass Filter exported as object
sound(Filtered)
plot(Filtered)
axis ([0 40000 -0.2 0.2])
title('Filtered
Signal in Time Domain')
xlabel('Time')
ylabel('Amplitude')
subplot(2,2,4)
Filteredfft =fft(Filtered);
fy =
(0:length(Filteredfft)-1)*Fs/length(Filteredfft);
plot(fy,Filteredfft)
title('Filtered
Signal in Frequency Domain')
xlabel('Frequency')
ylabel('Magnitude')
OUTPUT:
Part 2(b)
Applied Low Pass
Filter On Generated Audio
CODE:
rec =
audiorecorder(8000,8,1); %create an object for recording
record(rec,5); %record
for 5 seconds
data =getaudiodata(rec); %generate audio data
Fs =8000; %sampling
frequency
T = 1/Fs;
subplot(2,2,1)
plot(data)
axis ([0 50000 -0.4 0.4])
title('Original
Signal in Time Domain')
xlabel('Time')
ylabel('Amplitude')
subplot(2,2,2)
ty = fft(data);
f =
(0:length(ty)-1)*Fs/length(ty);
plot(f,ty)
title('Original
Signal in Frequency Domain')
xlabel('Frequency')
ylabel('Magnitude')
subplot(2,2,3)
Filtered
=filter(Hdhighy,data); %Hdhighy
is the High Pass Filter exported as object
sound(Filtered)
plot(Filtered)
axis ([0 50000 -0.4 0.4])
title('Filtered
Signal in Time Domain')
xlabel('Time')
ylabel('Amplitude')
subplot(2,2,4)
Filteredfft =fft(Filtered);
fy =
(0:length(Filteredfft)-1)*Fs/length(Filteredfft);
plot(fy,Filteredfft)
title('Filtered
Signal in Frequency Domain')
xlabel('Frequency')
ylabel('Magnitude')
OUTPUT:
No comments:
Post a Comment