Professional Documents
Culture Documents
Remarks: ……………………………………………
Experiment # 1
Introduction to Control Systems, Laplace Transform and
MATLAB / Simulink
Objectives
1. Introduction to Control Systems.
2. Introduction to Matlab/Simulink.
3. Basic Modeling in Simulink.
Software:
MATLAB v7 or latest
2.1 Matrices:
For entering the matrices we followed some basic rules which are as follows: Separate the
elements of the row with a blank or comma. Use a semicolon (;) to indicate the end of
each row. Surround the entire list of elements with square brackets, [ ].
Example:
A = [1 3 2 95; 53 0 1 5; 1 3 8 99; 4 5 1 3];
2.8 Finding derivative and use of syms command for defining variable
>>syms x y
>> f=exp(x*y)
>>diff(f);
2.10 Plotting
The most frequently used function is the plot function, which can accept different
arguments and gives different forms of plots for different equation. t=0:pi/100:6*pi;
y=sin(t); plot(t,y) grid on title(‘text’) xlabel(‘text’) ylabel(‘text’)
plot(t,y,’Y’) // Y means yellow color
plot(t,y,’Y-’) // Y- means yellow color with solid line
Given three inputs (r,p and k), residue convert back to polynomial form. >>
[b,a]=residue(r,p,k)
b=
1 4
a=
1.0000 2.0000 6.0000
MATLAB Implementation
Syntax
laplace(f)
laplace(f,transVar)
laplace(f,var,transVar)
Description
laplace(f) returns the Laplace Transform of f. By default, the independent variable is t and
transformation variable is s.
laplace(f,transVar) uses the transformation variable transVar instead of s.
laplace(f,var,transVar) uses the independent variable var and the transformation
variable transVar instead of t and s, respectively.
Example 1
syms f(x)
f(x) = x^4-2*x^3+6*x^2-2*x+10
f(-5)
Example 2
syms y1 y2
y1 = x+3; y2 = 3*x;
solve(y1 == y2)
Example 3
syms x y
factor(y^6-x^6)
Example 4
>> syms t
>> f=t^5;
>> laplace(f)
Example 5
>> f=exp(-5*t);
>> F=laplace(f)
Example 6
>> syms w t;
>> f=cos(w/2*t) ;
>> F=laplace(f)
Syntax
ilaplace(F)
ilaplace(F,transVar)
ilaplace(F,var,transVar)
Description
ilaplace(F) returns the Inverse Laplace Transform of F. By default, the independent variable
is s and the transformation variable is t. If F does not contain s, ilaplace uses the
function symvar.
ilaplace(F,transVar) uses the transformation variable transVar instead of t.
ilaplace(F,var,transVar) uses the independent variable var and transformation
variable transVar instead of s and t, respectively.
Example 1
Compute the inverse Laplace transform of 1/s^2. By default, the inverse transform is in
terms of t.
syms s
F = 1/s^2;
ilaplace(F)
Example 2
>> a = ilaplace(120/s^6)
Example 3
>> F=1/(s+a)
>> f=ilaplace(F)
Example 4
>>syms s w
>> F=s/(s^2+w^2)
>> f=ilaplace(F) f =cos(w*t)
>> simulink
and hit enter. This command displays a browser containing icons for the subsystem blocks
that make up the standard library, called the SIMULINK LIBRARY, as shown in figure – 1
on next page.
Click on File and New in the simulink window and, if required, move the new opened
window to a comfortable position.
Figure–1
Investigate all blocks falling under the Simulink tab only, especially Continuous, Math
Operations, Sinks and Sources.
Example:
Suppose we want to implement the system which generates sine wave using Simulink.
To implement the system we need two blocks.
1. Source which generates sine wave
2. Device to see output
In Simulink step wave falls under category of Sources. Output is seen at oscilloscope in
Sink category. Here is how we implement the system
1. Open library browser. From Sources category select step wave block and drag it
to the model window
2. From Sink category, select scope (oscilloscope) and drag it to the model window.
You get the following window after getting the blocks.
Figure-2
3.4 Wiring Techniques
Use the mouse to wire the inputs and outputs of the different blocks. Inputs are located
on the left side of the blocks, while outputs are located on the right side of the blocks.
Figure-3
3.5 Help Windows
It can be obtained by double-clicking on the block. It can provide detailed information
about the different blocks
Example
Assemble the following diagram in your working window.
Simulink > Sources > Step \\ Step Input
Simulink > Math Operations > Sum \\ Summer
Simulink > Continuous > Transfer Fcn \\ Transfer Function
Simulink > Continuous > Integrator \\ Integrator
Simulink > Sinks > Scope \\ Oscilloscope
Figure – 5
3.6 Procedure
1. Enlarge the blocks, arrange into order, and link the blocks together. Blocks can be
expanded/enlarged by dragging the corner indicators outward with the mouse. To
link the blocks, drag and connect the first block’s output arrow to the input
arrow of the second block using the left mouse button.
2. Double click on the Step, Sum or Transfer Function block and change the
coefficients, if required.
3. Click on File > Save and name your model.
4. Click on Simulation > RUN and observe the trace on the Scope by double-clicking
on it.
5. Ctrl R is the shortcut key to rotate the blocks.
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/
A good link for the tutorials related to simulink can be accessed using the above URL.
Figure-6
Figure-7
The above two figures shows Simulation 1 and Simulation 2 for the same system.
Simulation 1
Consider a system with the transfer function same as Integrator. Input to this system is a
step function. In response to this input, the system’s output will be a Ramp as shown
below. Another block, Gain, is attached in between the input and system. This gain will
affect the output. Change its different values to see different responses.
Figure-8
Simulation 2
An advantage associated with this system is that it has faster response. Again change the
values of Gain block to see different responses.
Figure-9
Exercise
Q.1 Consider figure 6 and 7 for this question.
1. Find the Step Response of the Transfer Function (Integrator), both for Open and
Closed loop.
Q.2 Consider a block diagram for RC circuit in fig 10. As we know that T=RC, is the charging
time for capacitor.
Change the value of time constant and draw its response on scope.
i. T=100ms ii. T=200ms iii. T=1s
Q.3 Find Laplace and inverse Laplace transform of following using MATLAB.
f(t) = eat
f(t)=1/sqrt(x)
___7s2+9s+12__
s(s+7)(s2+10s+100)
Q.5 Consider two polynomial, p(s)=s2+2s+1 and q(s)=s+1. Using MATLAB compute,
1. p(s) * q(s)
2. Roots of p(s) and q(s)
3. p(s)/q(s)