In control system, mathematical modelling plays an important role. With the presence of mathematical equation, differential equation is often present in it. And we must solve for its solution, and here comes the Laplace transform. If you want to learn about the Laplace transform you can google it. You still need to manually solve for Laplace transform because as an engineer, it’s a must. We have the most powerful tool, MATLAB®, but manual solving is an engineer’s must skill. But nevertheless, Matlab will surely help us solve for the solution.
So to start,
I want you to pick up your pen/pencil and solve for the Laplace transform of
this equation:
t3u(t) <--> ??
Did you get it? So let me help you,
Solution:
t4u(t) = โ{t4}
tn
= t4 = f(t)
F(s)
= โ{f(t) = t4}
= n!/sn + 1 = 24/s5
Let’s check in MATLAB. In order to do it in
MATLAB, we need to have a variable (just like in the equation we need to use
the letters ‘s’ and ‘t’). A variable which has no value, but just a symbol for
our computation. To do this, we type:
>>syms s t w x
Then we type our function:
>>Fs = laplace(t^3) %use capital Fs to denote it is in
laplace form
Fs =
24/s^5
So we are correct in our manual computation. What
if we are given the Laplacetransorm and we need to get the function. It’s easy,
again we type:
>>syms s t w x %with space each letters and from syms
>>ft = ilaplace(24/s^5) %use small ft to denote the function
ft =
t4
another example:
>>ft = ilaplace((s+1)/(s^3+5*s+6))
ft =
2*exp(-3*t) – exp(-2*t) %exp
means the letter ‘e’ function in our calculator or the euler’s constant
So that’s it the basic of laplace
transform. You could try more challenging laplace transform, or other function.
Just try also to solve it manually and to be not too much dependent on the software.
Thanks.
Simulink is
one the powerful toolboxes in Matlab which is used for graphical representation
of model systems and their simulations. In this, block diagrams are used as
different elements of the system. You can also use an output virtual port such
as spectrum analysers, error checkers and others. So to start, you can type,
>>Simulink
Or you can
click the Simulink Library Browser here: (the one in yellow box)
You can use
the search button to find the block element you need.
From here,
you can start putting a simple system like this, I’m making a simple
transmission system:
You can
change the blocks parameter by double clicking the icon. You must connect the
blocks in the system, to do this click the arrow icon, before or after the
block element and drag it to the next block element you want. So, for the block
properties of each element I used these values:
Random Integer: FM Modulator Passband: Square root: Gain:
M-ary number
= 2 Carrier frequency = 300 *default settings Gain = 5
Initial seed
= 37 initial phase = 0
Sample time =
1.2945e-8 frequency deviation = 50
Output data
type: double
*uncheck everything
For the scope, I
used the spectrum analyzer block with default settings.
After placing and connecting all the blocks click the play button at the top and look at the result. Here is
what I got. Check/solve also manually if the output you desire is correct.
Before we plot a graph on matlab we should specify what will be our x axis and our y axis. For instance, we could let x be the independent variable
and y is a function of x.
If we want to plot a cosine
function we could type:
>> t = 0:0.001:5; %this means, the first number 0
is the initial value and 5 is the last value,
%the
0.001 is the increment of the cosine function,
%NOTE:
make sure to put a semi-colon after every syntax
>>y =
cos(t-0.25); %our function;
>>plot(t,y,’r’) %plot
syntax; ‘r’ means the color of the line is red
You should have a graph like this:
We could also put title, label on our
graph:
>>title(‘Cosine plot’)
>>xlabel(‘time’)
>>ylabel(‘Amplitude’)
That’s it for plotting graph..you could
place two or more graphs in one figure.
You could start MATLAB by
clicking the MATLAB icon on windows, and once started, it will pop up and
display something like this:
And now you are now in MATLAB.
Command for MATLAB:
>> exit %to exit….. the symbol “%”
without quotes is used to put comments into your
%algorithm so I’ll use this symbol to put what the syntax is all about
%algorithm so I’ll use this symbol to put what the syntax is all about
>>help syntax %displays the syntax function
and its uses.. syntax is variable
%example:
>>help plot; or help sine
Now try this exercise:
>>x=2;
>>y=4;
>>z=x+y;
>>z %now if you will type the
letter z, it will look like this
z =
6
MATLAB uses conventional
decimal notation and the one we called PEMDAS rule in mathematics (Parenthesis Exponent Multiplication Division Addition Subtraction),
so if you will type;
>>z=3+7*8; %it is just like z= 3+ (7*8)
>>z
z =
59
>>pi %the constant pi = 3.1416
>>sqrt %the square root operation
>>6^2 %the symbol ^ means raised to
the nth so 6^2 means 6 squared,
ans =
36
>>sin(pi/2) %sine function of pi divided by 2, make
sure you put a parenthesis after the function
ans =
1
MATRIX
Matrix operation can also be
done in MATLAB. Columns are separated by space, and the rows are separated by
semicolon:
>>A = [1 2 3; 4 5 6; 7 8
9]
A =
1 2 3
4 5 6
7 8 9
I want you to explore every
possible outcome by using some matrix operations, and functions:
+ %addtion Inv %inverse of matrix
- %subtraction det %determinant of a matrix
* %matrix multiplication size %size of the matrix
^ %power rank %rank of matrix
‘ %transpose rand %random matrix number
\ %left division
/ %right division
>>F=rand(3,3)
F =
0.8147
0.9134 0.2785
0.9058
0.6324 0.5469
0.1270
0.0975 0.9575
That’s it for now… Up Next! I’ll
teach you how to plot in MATLAB
Before machines were made, automatic conveyor systems were installed, and before every controlled systems were put into operation –they were first modeled. Modelling a system lessens the expenses required in doing a trial and error on a system by making an algorithm or putting the system into mathematical equations. It predicts possible outcomes of a certain input was processed into the system. In short, modelling helps engineers design a system suitable for operation without expending too much. And in order to facilitate this modelling, a powerful software must be used. It should have a capacity to simplify a solution to a complicated mathematical model. And of course, the software must be within our reach. And this, is where MATLAB and Simulink play their role. You could download your MATLAB program here, it is pre-installed already with Simulink Toolbox. So, download it now while I help you to get started with MATLAB and design your own control system.So stay tuned and let me help you to know your MATLAB.