Tuesday, 31 January 2017

Control Systems Engineering with MATLAB - 1

Hello guys,
I hope you liked my previous blog on making your own R packages. If you haven’t yet seen it, please have a look at it here|How I made my first R Package?.


Today, I will do some very elementary Control system using MATLAB.


This blog post will have a little mathematics, so, brace yourselves.


Whenever, we talk of transfer functions, we think of Transfer functions, now what are transfer functions?
To keep it simple, if your = and your = ,
Then, the transfer function is given by the ratio of the laplace transform of the change in to the change in , mathematically,


= , here means Transfer function in -domain; Laplace domain is generally callled the -domain.


I believe, this is a very common fact. Now, let’s do some MATLAB.


We define a transfer function in MATLAB using the function tf function.


An illustration is as follows,
Imgur


You can change the co-efficients as you wish. just change the numbers inside the [ ].


For example,
H = tf([1 2], [1 2 3]), will yield,
=


Now, we convert the transfer function from to , basically from continuous to discrete domain,


For this, we use the c2d function, which is basically the continuous to discrete function for MATLAB.


The function looks like G = c2d(_transfer function_, _sampling time_),
So, for,
H = tf([1 2], [1 2 3])
the c2d function when applied will look like,
G = c2d(H, 0.1) 
0.1 second is the sampling time.


Have a look at this picture,
Imgur


Similarly, the d2c command also does the reverse, but, as your intuition speaks, since we are going into the continuous from the discrete domain, we don’t need a sampling time.


So, the syntax is,

I = d2c(G)


Look at the image below,
Imgur




That is all for today folks. In the next blog, I will be talking about Gain and Phase margins, Bode Plots and various other control engineering concepts.
Cheers!

No comments:

Post a Comment