Basics of Matlab & Simulink

Tibor Kasas
Q agency
Published in
2 min readJun 27, 2019

Matlab is a scientific tool that is designed for scientists and engineers. It is a programming platform with which you can analyze data, develop algorithms and create models and applications. Matlab is mostly used in industry and education for numerous fields such as signal processing and communications, control systems and various computation.

Here is an example of how to get a transfer function matrix. In this example you can also see how to check controllability and observability.
There is also the procedure of calculating the frequency and the period of the oscillations.

clear
A_=[2 3; 3 2]
B_=[1 0; 0 1]
C_=[1 0; 2 -1; 3 2]
D_=[0 0; 0 0; 0 0]
[num1, den]=ss2tf(A_, B_, C_, D_, 1)
[num2, den]=ss2tf(A_, B_, C_, D_, 2)
G11=tf(num1 (1,:), den)
G12=tf(num1 (2,:), den)
G13=tf(num1 (3,:), den)
G21=tf(num2 (1,:), den)
G22=tf(num2 (2,:), den)
G23=tf(num2 (3,:), den)
p=roots(den)
sys=ss(A_, B_, C_, D_)
c=rank(ctrb(sys))
o=rank(obsv(sys))
w_p1=imag(p(1))
w_p2=imag(p(2))
w_p3=abs(p(1))
w_p4=abs(p(2))
T_p1=2*pi/w_p1
T_p2=2*pi/w_p2
T_p3=2*pi/w_p3
T_p4=2*pi/w_p4
F_p1=1/T_p1
F_p2=1/T_p2
F_p3=1/T_p3
F_p4=1/T_p4
Tsim=10*T_p1

Simulink is a great tool for automatic control and digital signal processing, as well as for model based design. This is because of its tight integration with Matlab. Simulink is a graphical programming environment for modeling, simulating and analyzing multidomain dynamical systems. The basis of the Simulink interface is a graphical block diagramming tool with a customizable set of block librarires.

This is the Simulink library browser

In this simulation scheme you can see a simple nonlinear system with a subsystem called “Nonlinear model”.

Simple nonlinear system

And here, in the same example, you can see the simulation scheme for recording the response of a linear and nonlinear system model.

Expanded system

The nonlinear model subsystem that is the centre piece of this system is shown in detail view in the following image.

Detail view of the nonlinear model

--

--