PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

42 Practical MATLAB® Applications for Engineers


R.1.123 The MATLAB function un = dstep(P, Q, n) returns the discrete step response with
length n of the system defi ned by the transfer function H(z) = P(z)/Q(z).


R.1.124 For example, create the script fi le disc_ step that returns the discrete response in the
form of a table and a plot for a sequence of length n = 10 , for the system defi ned in
R.1.122.


MATLAB Solution
% Script file: disc _ step
clc; clf;
n = 10;
P = [2.24 2.5 2.25];
Q = [1 .5 .68];
un = dstep(P,Q,n);
nn = 0:1:9;
results = [nn’ un];
disp(‘****************************************************************’);
disp(‘The discrete step sequence u(n) for the first 10 samples is:’);
disp(‘^^^^^^^^^^^^^^’)
disp(‘ n u(n)’)
disp(‘^^^^^^^^^^^^^^’)
disp(results);
disp(‘****************************************************************’);
yzero = zeros(1,10);
stem (nn,un); hold on; plot (nn,yzero)
title (‘Discrete step response u(n) vs n’)
xlabel (‘time index n’);
ylabel (‘Amplitude[u(n)]’);

FIGURE 1.37
Discrete impulse response h(n) of R.1.122.


Discrete impulse response h(n) versus n
2.5

1.5

0.5

−0.5

1

0

− (^10123456789)
2
Amplitude [h(n)]
time index n

Free download pdf