forward rectangular rule to discretize a transfer function in matlab

The rectangular rule is a method to discretize a continuous-time transfer function. In Matlab, this can be done using the c2d function which has a default setting of using the rectangular rule.

Here's an example code snippet to forward rectangular rule to discretize a transfer function in Matlab:

main.m
% define the continuous-time transfer function
s = tf('s');
G = 1/(s+1);

% define the sampling time
Ts = 0.1;

% use the c2d function to discretize with the rectangular rule
Gd = c2d(G, Ts);
192 chars
10 lines

The resulting Gd object will be a discrete-time transfer function that has been obtained by discretizing the original transfer function G using the rectangular rule with a sampling time of Ts.

gistlibby LogSnag