Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

To write a MATLAB program to find the total response of a system defined by a difference equation.

%Let the difference equation be y(n)-y(n-1)+0.9y(n-2)=x(n) %To plot the impulse and step response for n = -20.-19,....100 clc; %Clear the command window

b=[1]; a=[1 -1 0.9]; n=[-20:100];

%Generating the impulse response x=[n==0]; y=filter(b,a,x); subplot(2,1,1) stem(n,y,'.') xlabel('Values of N') ylabel('h(n)') title('Impulse response') %Generating the step response x=[n>=0]; y=filter(b,a,x); subplot(2,1,2) stem(n,y,'.') xlabel('Values of N') ylabel('s(n)') title('Step response') COMMAND WINDOW OUTPUT ::PROGRAM TO FIND THE TOTAL RESPONSE FROM THE DIFFERENCE EQUATION::>

The values for the total response for given differential equation are ::4 13 24 31 -42

calculated

You might also like