A subject of example is a RLC circuit with four terminals. The considered circuit is constructed in specified way. The capacitor C and the coil L are connected in parallel. Connecting these elements in this way causes the output voltage (the output signal) to be tied in following relation u_2(t) = u_C(t) = u_L(t). The input voltage(input signal) u_1(t) is applied between the input terminals of the circuit. In purpose of solving the example the Kirchhoff’s current law (KCL) and Kirchhoff’s voltage law (KVL) have to be used. A transfer function of circuit and afterwards state space representation equations will be designated. It has to be remembered that number of state variables is equal to number of energy storages. In considered circuit energy storages are capacitor C and coil L.

The subject circuit is treated as a voltage divider. It will have its resultant impedance calculated in a Laplace transformation form. It is assumed that initial (start) conditions for Laplace transformation as equal to zero (ST=0). Firstly, the Laplace transformation of capacitor’s and coil’s admittance will be computed. A relation for admittance is used because elements are connected in parallel.

The circuit’s resultant impedance is the equal to:

The transfer function H(s) is designated by using formula for a voltage divider:

The general form of state space representation equations is following:

Where:

[A]- state matrix, [B]- input matrix, [C]- output matrix, [D]- feedthrough matrix

Calculating of the state space representation equations is started by writing Kirchhoff’s voltage law (KVL) equation for circuit. Kirchhoff’s current law (KCL) equation:

The Kirchhoff’s voltage law (KVL) equation:

The state space representation, state matrix [A] and input matrix [B]:

Since u_2(t) = u_C(t) = u_L(t)

The state space representation, output matrix(vector) [C] and feedthrough matrix(vector) [D]:

Two dynamic models have been designated for RLC circuit. The first model is in form of transfer function. The second model is in from of state space representation equations. All necessary data is in place to execute a simulation in MATLAB.

The simulation of the system’s response for a jump extortion it’s possible through lsim function. Firstly, a MATLAB’s m-file needs to be created with declarations of parameters of the electric circuit.

lsim(c,d,uin,t)

where:

c – vector with factors from counter of transfer function H(s)

d – vector with factors from denominator of transfer function H(s)

uin – vector with values for extortion

t – time vector

Sample code to executing simulation:

R=100;%resistance value

L=0.01;%inductivity value

C=0.001;%capacity value

t=0:0.000001:1;%time vector definition

uin=ones(1,length(t));%definition for unit extortion with application of ones function

l=[1];%vector with transfer function counter factors

m=[R*C 1 R/L];%vector with transfer function denominator factors

lsim(c,d,uin,t);

MATLAB is really very powerful calculation tool. It has in its resources functions which allow us to plot impulse response characteristic, step response characteristic and frequency response characteristics.
impulse(A,B,C,D)

step(A,B,C,D)

bode(A,B,C,D)

Using specified above functions we can plot characteristics of object. It is necessary to give input parameters as: state matrix, input matrix, output matrix and feedthrough matrix. In considered example appearance of input parameters is following:

MATLAB gives a possibility to create custom functions i.e. a custom library functions. A plenty of functions which are in MATLAB’s library were defined by users and shared with others. Therefore, everybody can contribute in the development of MATLAB's libraries.