Sie sind auf Seite 1von 6

DE LA SALLE UNIVERSITY – DASMARINAS

Dasmarinas, Cavite
COLLEGE OF ENGINEERING, ARCHITECTURE, AND TECHNOLOGY

ELECTRONICS ENGINEERING

Name: Moldez, Zharina Lorraine C. Date Performed: April 26, 2019


Course-Year & Section: ECE42 Rating:

Experiment No. 6
Different Equation
OBJECTIVES:
This experiment will enable the students to learn the concept of solving difference equation by
using the filter function in Matlab. The impulse response of a system will be obtained using the filter
function or by using the impz function in Matlab.

INSTRUMENTS AND MATERIALS NEEDED:


PC with MATLAB SOFTWARE INSTALLED

PROCEDURE:

A function called filter is available to solve difference equations numerically, given the input and
difference equation coefficients. It is invoked by
𝑦 = 𝑓𝑖𝑙𝑡𝑒𝑟(𝑏, 𝑎, 𝑥)
where, b = [b0, b1, …, bM]
a = [a0, a1, …, aN]
x = input sequence array
To compute and plot impulse response, MATLAB provides the function impz and is invoked by
ℎ = 𝑖𝑚𝑝𝑧(𝑏, 𝑎, 𝑛)

Sample Problem:
Given the following difference equation
Sample Problem:
Given the following difference equation:

𝑦(𝑛) − 𝑦(𝑛 − 1) + 0.9𝑦(𝑛 − 2) = 𝑥(𝑛)


a. Calculate and plot the impulse response h(n) at n = -20…100
b. Calculate and plot the step response s(n) at n = -20…100
c. Calculate and plot the system response y(n) when the input is u(n) – u(n – 10)

Open an m-file in Matlab, type the following script:


Approach 1:
>> % to obtain impulse response using impz
>> b = [1]; a = [1, -1, 0.9]; n = [-20:100];
>> h = impz(b, a, n);
>> subplot (3, 1, 1); stem (n, h);
>> title (‘Impulse Reponse’); xlabel(‘n’); ylabel(‘h(n)’);

OUTPUT:
Approach 2:
>> %to obtain impulse response using filter
>> x = impseq(0, -20, 100);
>> h = filter (b, a, x);
>> subplot(3, 1, 1); stem (n, h);
>> title(‘Impulse Resposne’); xlabel(‘n’); ylabel(‘h(n)’);

>> %to obtain step response


>> x = stepseq(0, -20, 100);
>> s = filter (b, a, x);
>> subplot(3, 1, 2); stem(n, s);
>> title(‘Step Response’); xlabel(‘n’); ylabel(‘s(n)’);

>> %to obtaib the system response


>> x = stepseq(0, -20, 100) – stepseq(10, -20, 100);
>> y = filter (b, a, x);
>> subplot (3, 1, 3); stem(n, y);
>> title(‘System Reponse’); xlabel(‘n’); ylabel(‘y(n)’);

OUTPUT:
Task:
A DL-LTI system is described by a second order equation
𝑦(𝑛) − 0.5𝑦(𝑛 − 1) + 0.25𝑦(𝑛 − 2) = 𝑥(𝑛) + 2𝑥(𝑛 − 1) + 𝑥(𝑛 − 3)
a. Calculate and plot the impulse response of the system over 0 … 100
b. Calculate and plot the system response to the input,
𝑥(𝑛0 = [5 + 3 cos(0.2𝜋𝑛) + 4 sin(0.6𝜋𝑛)𝑢(𝑛) 𝑜𝑣𝑒𝑟 0 … 100

OUTPUT:
CODES:
function [x,n] = impseq(n0,n1,n2)
%Programmed By: Moldez, Zharina if ((n0 < n1) | (n0 > n2) | (n1 >
Lorraine C. n2))
%ECE42 error('arguments must satisfy n1
%ECET423La <= n0 <= n2')
%April 26, 2019 end
%Instructor: Engr. Katrina Acapulco n = [n1:n2];
x = [(n-n0) == 0];
clc FOR STEPSEQ:
%Programmed By: Moldez, Zharina
%Impulse Response Lorraine C.
b= [1,2,0,1]; %ECE42
a = [1,-0.5,0.25] ; %ECET423La
n=[0:100]; %April 26, 2019
x = impseq(0,0,100); %Instructor: Engr. Katrina Acapulco
h=filter(b,a,x); function [x,n] = impseq(n0,n1,n2)
subplot(2,1,1); if ((n0 < n1) | (n0 > n2) | (n1 >
stem(n,h); n2))
title('Impulse error('arguments must satisfy n1
Response');xlabel('n');ylabel('h(n)' <= n0 <= n2')
); end
grid on; n = [n1:n2];
x = [(n-n0) == 0];
%System Response function [x,n]=stepseq(n0,n1,n2)
nx=(5+3*cos(0.2*pi*n)+4*sin(0.6*pi*n if((n0<n1)|(n0>n2)|(n1>n2))
)).*stepseq(0,0,100); error('arguments must satisfy
yfilter = filter(b,a,nx); n1<=n0,n<=n2')
subplot(2,1,2); end
stem(n,yfilter); n=[n1:n2];
title('System x=[(n-n0)>=0];
Response');xlabel('n');ylabel('y(n)'
); FOR IMPSEQ:
grid on; function [x,n] = impseq(n0,n1,n2)
if ((n0 < n1) | (n0 > n2) | (n1 >
FOR IMPSEQ: n2))
%Programmed By: Moldez, Zharina error('arguments must satisfy n1
Lorraine C. <= n0 <= n2')
%ECE42 end
%ECET423La n = [n1:n2];
%April 26, 2019 %x = [zeros(1,(n0-n1)), 1,
%Instructor: Engr. Katrina Acapulco zeros(1,(n2-n0))];
x = [(n-n0) == 0];
ANALYSIS AND DISCUSSION:

In this experiment, Different Equations, introduces the sequence


correlation of signals and presents the sequence correlation of signs. The
cross-relationship measures closeness among x and shifted(lagged) copies of y
as a component of the slack. The PC examination of the acknowledgment
structures of discrete frameworks is performed much the same as with the
technique for nodal voltages in simple circuits and frameworks, and is of
principal noteworthiness in the investigation of the properties of discrete
frameworks. Filter are broadly utilized as a part of gadgets, broadcast
communications, radio, TV, music combination, PC designs, and some more
applications. It is a gadget that expels generally bothersome segments or
structures from the got flag. Its procedure is called sifting where it is
generally utilized as a part of expelling a few frequencies or scope of
frequencies. Despite the fact that this doesn't work dependably or act in the
recurrence, or maybe it can evacuate relationships for certain recurrence
segments in the field of picture handling and numerous different viewpoints.

For a graphical representation of difference equations both block diagrams and


signal flow graphs can be used. In addition to the classical mathematical
analysis the Z-transform is frequently used to solve difference equations. In
reverse examination of the transfer function implemented in the z-transform,
Mason’s gain rule can be used for the calculation of graph transfer from the
chosen input node to the output node. The computer analysis of the realization
structures of discrete systems is performed much the same as with the method
of nodal voltages in analog circuits and systems, and is of fundamental
significance in the analysis of the properties of discrete systems.

CONCLUSION:

In conclusion, solving the problems while following and understanding that


different equation is an equation containing finite differences of an unknown
function the students were able to perform and execute all the given exercises
in the experiment successfully. In addition to that, the students were able to
know the basics in contrast condition, how to comprehend it in MATLAB and the
two ways in utilizing, which are the utilizing the impz code structure and the
filter sentence structure. In addition, the student played out the analysis
effectively and will have the capacity to utilize the scholarly basics in the
up and coming applications. There were some difficulties and errors
encountered in making the programs for some exercises, however the students
have occurred to do a solution for these errors appeared in the MATLAB.

Das könnte Ihnen auch gefallen