
Difference equations
Finding transfer function using z-transform
Derivation of state-space from difference equations
MATLAB representation

We assume that the function f is linear and depends only on a finite number of signals e's and u's. Then the basic structure of the difference equation can be written as

For a while, we will consider the following difference equation (1).
(1)Recall that a transfer function for the continuous system we have been considering so far was derived by first taking the Laplace transform of differential equations and then solved for Output/Input in terms of s. To derive the transfer function in discrete form, the mathematical tool very similar to the Laplace transform called z-transform will be used.
The z-transform is defined by

where f(k) is the amplitude of a sample, and the value k = 0, 1, 2, 3, ... refer to the discrete sample time.
Analogously, this can lead to the relation

By using these relations, we can easily find the discrete transfer function of a given difference equation.
Suppose we are going to find the transfer function of the system defined by the above difference equation (1), first, apply the above relations to each of u(k), e(K), u(k-1), and e(k-1) and you should arrive at

After few steps of algebra, you will have the following transfer function in discrete form (2).
(2)
Matrices F, G, H and J are the discrete versions of A, B, C, and D for the continuous case.
We can express the system in state-space form as follows:

numDz=[1 -0.95]; denDz=[1 -0.75]; sys = tf(numDz,denDz,-1);The -1 tells MATLAB that the sample time is undetermined.
F=.75; G=.5; H=-.4; J=1; sys = ss(F,G,H,J,-1);Again, a -1 is used for an undetermined sample time.