Experiment No. 8 The Difference Equation
Experiment No. 8 The Difference Equation
Experiment No. 8 The Difference Equation
Exercises #04
The Difference Equation
>> x = u;
>> y = filter(b,a,x);stem(n,y);grid on;
axis([1 -1 -20 120]);
1. For each of the systems defined by difference equations, determine and plot the
impulse and step response. Use the Copy figure function of the MATLAB to plot the
output in a separate sheet of paper. Label each plots accordingly.
For (a):
>> x=u;
>> y = filter(b,a,x);stem(n,y);grid
on;axis([1 -1 -20 120]);
>> title('Step Response');
xlabel('time index n'); ylabel('y(n)')
For (b):
For (c):
For (d):
For (a)
>> x=u;
>> y = filter(b,a,x);stem(n,y);grid
on;axis([1 -1 -20 120]);
For (b):
>> n=[-30:30]; x=(0.5).^n.*(n>=0);
>> stem(n,x);grid
For (c):
>> n = [-15:15];
x = (0.5).^(n);
stem(n,x);
grid on;
xlabel('time index n');
ylabel('y(n)');
title('Impulse response');
F = conv2(y,x);
plot(F);
stem(F);
grid on;
For (d):
>> b = [1];a = [1 -1 0.9];
>> n = [-15:15];
>> xlabel('time index n');
>> ylabel('y(n)');
>> title('Impulse response');
>> y = filter(b,a,x);stem(n,y);grid
on;axis([1 -1 -20 120]);