You are on page 1of 66

A

LAB RECORD
ON
MATLAB SIMULATION

Submitted By:

DHARAVATH PAVAN KUMAR


(31804112)

Submitted To:

J.S. LATHER
Professor

Department of Electrical Engineering


NIT Kurukshetra
ASSIGNMENT 1
OBJECTIVE 1: Write a program to form with MATLAB matrices A(2X2), B(2X2) and
C(2X3) then compute the following matrices: AB, BA, A+B, BC, CC T, inverse(B),
BTAT, the determinant of A, the determinant of B.
A= [2 5; 1 9]
B= [6 1; 9 0]
C= [4 2 8; 1 9 5]
Solution

To define a row matrix in MATLAB, the user must enter the elements of the row separated by
commas or just space in a pair or square parenthesis. If the user wishes to define a matrix with
more than one row, then the current row must be terminated using a semicolon before entering
the elements of the next row.
Once all the matrices are defined, the user can perform various arithmetic operations with
them.
Matrix multiplication can be done with ‘*’ operator, addition with ‘+’ operator, transpose with
‘ ’ ’, determinant with det() function, inverse with inv() function. In Output functions, x is
showing multiplication and AT is showing transpose of A.

PROGRAM:
A = [2 5; 1 9]; %Defining Ma trix A of order 2x2 Where ;[] is used for new row
B = [6 1; 9 0]; %Defining Ma trix B of order 2x2 Where ; i n [] is used for new row
C = [4 2 8; 1 9 5];%Defi ning Ma trix C of order 3x2 Where ; i n [] is used for new row
AxB=A*B % Multiplying Matrix A and Matrix B
BxA=B*A % Multiplying Matrix B and Matrix A
sum_AB=A+B % Adding Matrix A and Matrix B
BxC=B*C % Multiplying Matrix B and
Matrix C
CxCT=C*C' % Multiplying Matrix C and Matrix
C’(C Transpose)
inv_B=inv(B) % Calculating inverse of Matrix B
BTxAT=B'*A' % Multiplying Matrix B’ and Matrix
A’ Det_A=det(A) % Calculating determent of Matrix
A Det_B=det(B) % Calculating determent of Matrix B

Solution:
AxB =
57 2
87 1

BxA =
13 39
18 45

sum_AB
=86
10 9
BxC =
25 21 53
36 18 72
CxCT =
84 62
62 107

inv_B =
0 0.1111
1.0000 -0.6667

BTxAT
= 57 87
2 1

Det_A
= 13

Det_B
=-9

OBJECTIVE 2:-To form with MATLAB the vector Q = [1 2 3 . . . . 10], R = [1 3 5 . . ..19] ,


S = [1 0.95 0.90 . . . . 0] and T = [1 2 3] then compute the sum of the square of the difference of the element
in the vector Q and R.

Solution:-
To define a row matrix whose elements form an arithmetic progression, the user must follow
the program: [first element: step size: last element]

PROGRAM:
Q = [1:1:10]; %Defining Matrix Q where :1 is used for unit difference in the span of 1-10
R = [1:2:19]; %Defining Matrix R where :2 is used for 2 difference in the span of 1-19
S = [1:-0.05:0] ; %Defining Matrix S where :-0.05 is used for -0.05 difference in the span of 1-0
T = [1 2 3]; %Defining Matrix T
M = (Q-R).^2 %Defining Matrix M, which is showing the square of difference of Matrix Q,R

RESULT

M=
0 1 4 9 16 25 36 49 64 81

OBJECTIVE 3: To form using MATLAB a vander matrix of degree n=5.

A = vander(v) returns the Vander monde Matrix such that its columns are powers of the
vector v
For input vector v=   [v1v2…vN], the Vander monde matrix is

(N−j)
The matrix is described by the formula A(i,j)=v(i) such that its columns are powers of the
vector v.

PROGRAM:

L = vander(1:1:5) % This command is used for vander matrix of order 5x5 with one difference

RESULT

L=

1 1 1 1 1
16 8 4 2 1
81 27 9 3 1
256 64 16 4 1
625 125 25 5 1

OBJECTIVE 4:-To form using MATLAB the matrix A= [1 11 111 1111; 2 22 222 2222; 3 33 333 3333]
How do you pick from matrix A:
• Second element of 3rd row
• Last two element of 1st row
• 2nd row entirely
• The last column entirely

Solution:-

To retrieve an element of a matrix from a certain row and column, the user must follow the
program: Matrix(row, column). If the user wishes to retrieve a row from a matrix the program
is Matrix(row,:) and for an entire column it is Matrix(:, column).

PROGRAM
J = [1 11 111 1111;2 22 222 2222;3 33 333 3333]
A = J(3,2)
B=J(1,3:4)
C =J(2,:)
D =J(:,4)
RESULT
J=
1 11 111 1111
2 22 222 2222
3 33 333 3333

A=
33

B=
111 1111
C=
2 22 222 2222

D=
1111
2222
3333

OBJECTIVE 5: To write a program to solve a general quadratic equation using MATLAB. Then
solve the following equations using it:
• 2 z2 + 0.68 z - 4 = 0
• 2z2 + 0.68 z + 4 = 0

Solution:-

MATLAB treats a row matrix as a polynomial when roots() function is used.

PROGRAM

X = [2 0.68 -4]
A = [2 0.68 4]
W = roots(A)
Y = roots(X)

RESULT
X=

2.0000 0.6800 -4.0000

A=

2.0000 0.6800 4.0000

W=

-0.1700 + 1.4040i
-0.1700 - 1.4040i
Y=

-1.5944
1.2544

OBJECTIVE 6: Find the singular value decomposition, Lower and Upper decomposition
of the matrix given by
101
A=234
167
Solution:-
s = svd(A) returns the singular values of matrix A in descending order.
[U,S,V] = svd(A) performs a singular value decomposition of matrix A, such that A = U*S*V'.

PROGRAM:

A = [1 0 1;2 3 4;1 6 7] %this command is used for defining matrix A


[U,S,V] = svd(A) %this command is used for singular value decomposition
Lower=tril(A) %this command is used for lower triangular
Upper=triu(A) %this command is used for lower triangular

RESULT

U=

-0.0881 -0.6236 -0.7767


-0.4936 -0.6500 0.5778
-0.8652 0.4343 -0.2506

S=

10.6865 0 0
0 1.6376 0
0 0 0.3429

V=

-0.1816 -0.9094 0.3742


-0.6243 0.4006 0.6706
-0.7597 -0.1119 -0.6405
Lower=
1 0 0
2 3 0
1 6 7

Upper =

1 0 1
0 3 4
0 0 7
OBJECTIVE 7:- To determine the values of x1, x2, and x3 for the following set of linear
algebraic equations:
x2 – 3x3 = – 5
2x1 + 3x2 – x3 = 7
4x1 + 5x2 – 2x3 = 10
Solution:-
We can solve a set of linear algebraic equation using MATLAB using the equation
Ax = B
Where A is then formed by the coefficients and B is a column matrix formed by the constants
on the right side of the equation. So the solution can be obtained by calculating
x = A-1*B
PROGRAM:

A = [0 1 -3 ; 2 3 -1 ; 4 5 -2] % Assuming Matrix A from given


equation B = [-5 ; 7 ; 10] % Assuming Matrix B from given
equation
K = inv(A) % Finding Inverse of A
X = K*B % Finding unknown values in order of X1,X2,X3

RESULT

A=

0 1 -3
2 3 -1
4 5 -2

B=

-5
7
10

K=

-0.1667 -2.1667 1.3333


0 2.0000 -1.0000
-0.3333 0.6667 -0.3333
X=

-1.0000
4.0000
3.0000
ASSIGNMENT 2

OBJECTIVE 1: To determine the eigenvalues and eigenvectors of A using MATLAB


4 2 -3
A= -1 1 3
2 5 7
Solution: -

e = eig(A) returns a column vector containing the eigenvalues of square matrix A.

PROGRAM:
A = [4 2 -3;-1 1 3;2 5 7]
[V,D]=eig(A)

RESULT

A=
4 2 -3
-1 1 3
2 5 7

V=

-0.6713 0.9163 -0.3905


0.6713 -0.3984 0.3905
-0.3144 0.0398 0.8337

D=

0.5949 0 0
0 3.00 0
0 0 8.4051

OBJECTIVE 2:
To solve
x2 – 3x3 = – 5
2x1 + 3x2 – x3 = 7
4x1 + 5x2 – 2x3 = 10
Solution:-

We can solve a set of linear algebraic equation using MATLAB using the equation
Ax = B
Where A is then formed by the coefficients and B is a column matrix formed by the constants
on the right side of the equation. So the solution can be obtained by calculating
x = A-1*B
PROGRAM:

A = [0 1 -3; 2 3 -1;4 5 -2] %Define matrix ‘A’


B = [-5;7;10] %Define matrix ‘B’
K = inv(A) %Inverse matrix of ‘A’
X = K*B %multiplication of matrix

RESULT

A=
0 1 -3
2 3 -1
4 5 -2
B=
-5
7
10
K=
0.1667 -2.1667 1.3333
0 2.0000 -1.0000
-0.3333 0.6667 -0.3333
X=
-1.0000
4.0000
3.0000
OBJECTIVE 3: To generate an overlay plot for plotting three lines
Y1=sin t , Y2=t , Y3=t-t.^3/factorial(3)+t.^5/factorial(5)+t.^7/factorial(7); 0 ≤ t ≤
2π Using
(1) the plot command
(2) the hold command
(3) the line command

Solution:-

In MATLAB any definition is done in the form of a matrix. That means by the instructions
t =0:0.5:2*pi
y1 = sin(t)
we are defining y1 as a row matrix of size 13.To perform any mathematical operation at an
elemental level the dot (.) operator must be used.For example if the user wishes to calculate a
matrix x, whose elements are the squares of the matrix y1, then the instruction that needs to be
executed is
x =y1.^2
But not
x = y1^2

PROGRAM

t=0:0.5:2*pi %Define time period


y1=sin(t); %Define finction y1
y2=t; %Define finction y2
y3=t-t.^3/6+t.^5/120+t.^7/5040; %Define finction y3
plot(t,y1,t,y2,t,y3); %Plot the graph between time and functions
xlabel('time');
ylabel('Amplude');
hold on %To hold the graph in one picture
grid on %For on the grids in graph

line(t,y1) %Show the Graph in combination of line


line(t,y2)
line(t,y3)
RESULT
t=
Columns 1 through 11
0 0.3142 0.6283 0.9425 1.2566 1.5708 1.8850 2.1991 2.5133 2.8274 3.1416

Columns 12 through 21
3.4558 3.7699 4.0841 4.3982 4.7124 5.0265 5.3407 5.6549 5.9690 6.2832
y1 =
Columns 1 through 11
0 0.3090 0.5878 0.8090 0.9511 1.0000 0.9511 0.8090 0.5878 0.3090 0.0000
Columns 12 through 21
-0.3090 -0.5878 -0.8090 -0.9511 -1.0000 -0.9511 -0.8090 -0.5878 -0.3090 -0.0000
y2 =
Columns 1 through 11
0 0.3142 0.6283 0.9425 1.2566 1.5708 1.8850 2.1991 2.5133 2.8274 3.1416
Columns 12 through 21
3.4558 3.7699 4.0841 4.3982 4.7124 5.0265 5.3407 5.6549 5.9690 6.2832
y3 =
Columns 1 through 11
0 0.3090 0.5878 0.8093 0.9530 1.0092 0.9838 0.9045 0.8287 0.8526 1.1233
Columns 12 through 21
1.8524 3.3330 5.9595 10.2505 16.8757 26.6864 40.7506 60.3920 87.2348 123.2526

Fig. y1, y2, y3 curves

OBJECTIVE 4: To plot the parametric space curve of ,

z = – 7 / (1 + x2 + y2) | x | ≤ 5 , | y | ≤ 5

Solution:-

PROGRAM:

X=linspace(-5,5)
Y=linspace(-5,5)
[x,y] = meshgrid(x,y); %limit the x,y surface
z= -7./(1+x.^2+y.^2); %Define the surface equation
mesh(x,y,z) %To plot the surface graph in 3-D

RESULT

Fig. Z curve

OBJECTIVE 5: To use diff command for symbolic differentiation of the following functions:
(a) S1 = ex8
(b) S2 = 3x3 ex5
(c)S3 = 5x3 – 7x2 + 3x + 6

PROGRAM:
syms x %To define the variable x
s1 = exp(x^8)
s2 = 3*x^3*exp(x^5)
s3 = 5*x^3-7*x^2+3*x+6
diff(s1) %To differentiate function s1
diff(s2) %To differentiate function s2
diff(s3) %To differentiate function s2
RESULT
s1 =
exp(x^8)
s2 =
3*x^3*exp(x^5)
s3 =
5*x^3 - 7*x^2 + 3*x + 6
ans =
8*x^7*exp(x^8)
ans =
9*x^2*exp(x^5) +
15*x^7*exp(x^5) ans =
15*x^2 - 14*x + 3
OBJECTIVE 6: To Use MATLAB’s symbolic commands to find the values of the following integrals :

Solution:

PROGRAM
syms x,y a %Define the variables
f1 = abs(x)
f2 =
cos(y)+7*y^2 f3
= sqrt(x)
f4 =7*x^5-6*x^4+11*x^3+4*x^2+8*x+9
f5= cos(a)
int(f1,0.2,0.7) %integrate the function f1 with in limit
int(f2,0.2,pi) %integrate the function f2 with in limit
int(f3) %integrate the function f3
int(f4) %integrate the function f4
int(f5) %integrate the function f4

RESULT
f1 =
abs(x)
f2 =
cos(y) +
7*y^2 f3 =
sqrt(x)
f4 =
7*x^5 - 6*x^4 + 11*x^3 + 4*x^2 + 8*x +
9 f5 =
cos(a)
ans =
9/40
ans =
(7*pi^3)/3 - sin(1/5) - 7/375
ans =
(2*x^(3/2))/3
ans =
(7*x^6)/6 - (6*x^5)/5 + (11*x^4)/4 + (4*x^3)/3 + 4*x^2 + 9*x
ans =sin(a)
OBJECTIVE 7: To obtain the partial-fraction expansion:
F(s) = 8(s+1)(s+3)/(s+2)(s+4)(s+6)(s+6)

PROGRAM:
b = [8 32 24] %Define the numerator coefficients
a =[1 18 116 312 288] %Define the denomator coefficients
[r,p,k] = residue(b,a) %To obtain residue and pole
RESULT:
b=
8 32 24
a=
1 18 116 312 288
r=
3.2500
15.0000
-3.0000
-0.2500
p=
-6.0000
-6.0000
-4.0000
-2.0000
k
=
[]
OBJECTIVE 8:- Generate the transfer function using MATLAB. Using ratio of
polynomials. G(s)= 3(s+9)(s+21)(s+57)/s(s+30)(s^2+5s+35)(s^2+28s+42)

PROGRAM:

z1=[1 9] % defining zero


polynomials z2=[1 21]
z6=conv(z1,z2) % convolution of two polynimials
z3=[1 57]
z4=conv(z6,z3)
z5=3*z4
p1=[1 0]
p2=[1 30]
p3=[1 5 35]
p4=[ 1 28 42]
p5=conv(p1,p2)
p6=conv(p3,p4)
p7=conv(p5,p6)
g=tf(z5,p7) % overall transfer function

RESULT:

Transfer function:
3 s^3 + 261 s^2 + 5697 s + 32319
--------------------------------------------------------
s^6 + 63 s^5 + 1207 s^4 + 7700 s^3 + 37170 s^2 + 44100 s

OBJECTIVE 9: -If a stone is thrown is vertically upwards with an initial speed u, its
vertical displacement s after a time t has elapsed is given by the formula s=u*t-0.5*g*t^2,
where g is the acceleration due to gravity. Air resistance has been ignored. Compute the
value of s over a period of about 12.3 seconds at intervals of 0.1seconds, and plot the
distance-time graph over this period.
Solution:-
PROGRAM:

t=(0:0.1:12.3); % Defining time period with time 0.1 second interval


g=9.8; % gravity acceleration
s=0.5*g*(t.^2); % Displacement equation
plot(t,s,'r') % Command for plot the graph between t v/s s
title('Stone throwing'); % To show the title on graph
xlabel('Time'); % Naming on x-axis
ylabel('Distance'); % Naming on y-
axis grid on

RESULT:
OBJECTIVE 10: Find 10!.
Solution:-
PROGRAM:

factorial(10) % factorial of the argument.

RESULT: factorial(10) = 3628800.


ASSIGNMENT 3

OBJECTIVE 1. Consider the function h(s) where n(s) = s^4 + 6s^3 + 5s^2 + 4s + 3 and
d(s) = s^5 + 7s^4 + 6s^3 + 5s^2 + 4s + 7. Find n(– 10), d(– 5), h(– 3) ,h(S)=n(s)/d(s)
Solution:-
PROGRAM:

a= [1 6 5 4 3] % Defining Matrix
b= [1 7 6 5 4 7] % Defining Matrix
h=tf(a,b) % Defining Transfer Function
A=polyval(a,-10) %Calculating Value of function n at -10
B=polyval(b,-5) %Calculating Value of function d at -5
H=evalfr(h,-3) %Calculating Value of function h at -3

RESULT
a=
1 6 5 4 3

b=

1 7 6 5 4 7

h=

s^4 + 6 s^3 + 5 s^2 + 4 s + 3


-------------------------------------
s^5 + 7 s^4 + 6 s^3 + 5 s^2 + 4 s +7

Continuous-time transfer function.

A=
4463
B=
612
H=
-0.2228
OBJECTIVE 2. Expand the following function F(s) into partial fractions using
MATLAB. Determine the inverse Laplace transform of F(s) = 1/(s^4+5s^3+7s^2)
Solution:-
PROGRAM:

syms s %for defining variable s


F = 1/(s^4+5*s^3+7*s^2); % defining given function of s
L = ilaplace(F) %This command is used for finding inverse laplace

RESULT
L= t/7 + (5*exp(-(5*t)/2)*(cos((3^(1/2)*t)/2) + (11*3^(1/2)*sin((3^(1/2)*t)/2))/15))/49 - 5/49

OBJECTIVE 3.For each of the second order systems below, find ξ, ωn, Ts, Tp, Tr,
% overshoot, poles, zeroes and plot the step response using MATLAB.
(a) T(s) = 130/(s^2+15s+130)

Solution:
PROGRAM
a = [130]; %defining Numerator
b = [1 15 130]; %defining Denominator
h = tf(a,b); % Defining Transfer Function using num, and den
step response=step(h) %command for getting step response
zeroes=zero(h) %calculating zeros of transfer function h
poles=pole(h) %calculating poles of transfer function h
damp(h) %calculating damping of transfer function h

Solution

zeroes =

Empty matrix: 0-by-1

poles =

-7.5000 + 8.5878i
-7.5000 - 8.5878i

Eigenvalue Damping Frequency

-7.50e+00 + 8.59e+00i 6.58e-01 1.14e+01


-7.50e+00 - 8.59e+00i 6.58e-01 1.14e+01

(Frequencies expressed in rad/seconds)

Fig. step response of [a]

(b) T(s) = 0.045/(s^2+0.025s+0.045)

RESULT:
a=
0.0450
b=
1.0000 0.0250 0.0450
Transfer function:
0.045

--------------------------------
s^2 + 0.025 s + 0.045
ans =
Empty matrix: 0-by-1
ans =
-0.0125 + 0.2118i
-0.0125 - 0.2118i
Eigenvalue Damping Freq. (rad/s)
-1.25e-002 + 2.12e-001i 5.89e-002 2.12e-001
-1.25e-002 - 2.12e-001i 5.89e-002 2.12e-001

Fig. step response[b]


(c) T(s) = 10^8/(s^2+1.325*10^8s+10^8)

RESULT
a= 100000000
b = 1 132500000 100000000
Transfer function:
1e008
-------------------------
s^2 + 1.325e008 s + 1e008
ans =
Empty matrix: 0-by-1
ans =
1.0e+008 *
-1.3250
-0.0000
Eigenvalue Damping Freq. (rad/s)
-7.55e-001 1.00e+000 7.55e-001
-1.32e+008 1.00e+000 1.32e+008

Fig.step response of (c)


OBJECTIVE 4: A plant to be controlled is described by a transfer function .obtain the root
locus plot using matlab G(s) = (s+5)/(s^2+7s+25)

Solution:-

PROGRAM

b= [1 5]
a= [1 7 25]
g= tf(b,a)
rlocus(g)
RESUL
T
b=
1 5
a=
1 7 25
Transfer function:
s+5
--------------
s^2 + 7 s + 25
OBJECTIVE-5:Determine the close loop poles and closed loop step response of system

PROGRAM:
b= [30 -150 90];
a= [1 12 49 78 40];
g= tf(b,a);
H=
feedback(g,1)
pole(H)
step(H)
ans =
-6.5005 + 6.9514i
-6.5005 - 6.9514i
0.5005 + 1.0885i
0.5005-1.0885i
RESULT:

OBJECTIVE-6: Draw a Bode diagram of the controller

G(s) = 29.125(s+0.57)^2/s

Solution:-
PROGRAM:

G = zpk([-0.57 -0.57],[0],29.125);
bode(g)

RESULT
ASSIGNMENT NO. 4

OBJECTIVE 1: For the unity feedback system determine the range of K for Stability
using MATLAB G(s) = k(s+1)/s(s+1)(s+5)(s+6)

Solution:

PROGRAM

K= 0:1:1000; %Defining the range of k


a= poly( [ 0 -1 -5 -6 ] ) %Defining the denominator polynomial
for i=1:length(k)
b= a+[ 0 0 0 k(i) k(i) ]
c=roots(b)
d=real(c)
e= max(d)
if (e>0)
break
end
end
k=k(i
)

RESULT:
a=
1 12 41 30 0
b=
1 12 41 55 25
c=
-7.4043 + 0.0000i
-1.7978 + 0.3797i
-1.7978 - 0.3797i
-1.0000 + 0.0000i
d=
-7.4043
-1.7978
-1.7978
-1.0000
e=
-1.0000
K
=
25

OBJECTIVE:-2. Write a program in MATLAB for the unity feedback system with so that
the value of gain k can be input. Display the bode plots of a system for the input value of K.
Determine and display the gain and phase margin for the input value of K. G(s) =
k/[s(s+3)(s+12)]

PROGRAM
k=input('enter the value of k') %Input the value of gain
G= zpk([ ],[0 -3 -12] ,10) %Transfer function in pole-zero form
bode(G); %To draw the bode plot of given transfer function
[Gm,Pm,Wg,Wp] = margin(G) %To obtain the different characteristics of bode plot

RESULT:
enter the value of k;25
k=
25
G=
10
--------------
s (s+3)
(s+12)
Continuous-time zero/pole/gain model. Gm
=
54.0000
Pm =
83.4143
Wg=6
Wp =0.2765

OBJECTIVE 3: Write a program in MATLAB for the system shown below so that the
value of K can be input (K=40)
(a) Display the closed loop magnitude and phase frequency response for unity
feedback system with an open loop transfer function, KG(s).
(b) Determine and display the peak magnitude, frequency of the peak magnitude, and
bandwidth for the closed loop frequency response for the input value
of K. C(s)/R(s) = K(s+5)/s(s^2+3s+15)
Solution:

PROGRAM
syms w %Defining system variable
w=0.1:0.1:1000; %Define the range of frequency
k=input('enter the value of open loop gain') %enter the value of k
G=tf([k 5*k],[1 3 15 0]) %Display the open loop transfer function
gc=feedback(G,1) %Display the closed loop transfer function
[a,b]=bode(gc,w)
bode(gc) %plot the bode graph
[d,i]=max(a)
w1=w(i)
b=0.707*d
for(i=1:length(a))
if(a(i)==b)
Break
End
end
bandwidth = w(i)
RESULT:
Enter the value of open loop gain 40
k = 40
Transfer function: 40 s + 200 / s^3 + 3 s^2 + 15 s
Transfer function: 40 s + 200 / s^3 + 3 s^2 + 55 s +
200
d = 11.0512
i = 75
w1 = 7.500
b = 7.8132
Bandwidth =1000
ASSIGNMENT NO. 5

OBJECTIVE 1: Design a compensator for following transfer functions to meet the given
specifications G(s)=1/((s+1)*(s+2)*(s+3))
 Mp ≤ 16%
 tr ≤0.6sec
Solution:-
PROGRAM:
s=zpk('s') %Defining system variable
h=zpk([ ],[-1 -2 -3],1) %Defining pole zero form
sisotool(h) %opening the tool window for designing compensator
Zero/pole/gain:
1
H(s)= ---------------------
(s+1) (s+2) (s+3)
Root locus plot without compensator
Step response without compensator
After adding design constraints in sisotool to achieve required compensator we get following
plot

RESULT:-The Bode and Root locus plot shows desired characteristic with compensator.
RESULT:-The Step Response plot shows desired characteristic with compensator.
OBJECTIVE 2: Design a compensator for following transfer function to Meet the given specifications

4500
G(s) = -----------
-- s(s+361.2)
(i) Steady-state error due to unit-ramp input 0.000443
(ii) (ii) Maximum overshoot ≤ 5 percent
(iii) (iii) Rise time tr ≤ 0.002 sec
(iv) (iv) Settling time ts ≤ 0.005sec
Solution:
PROGRAM:
num=4500; %Defining numerator
den=[1 361.2 0]; %Defining denomator
G=tf(num,den) %Defining transfer function
sisotool(G) %Opening tool window for designing
compensator Plot without compensator
Now adding design constraints
RESULT- The desired characteristics are achieved and shown in the figure.
Figure:- Root locus plot of the desired system

Fig-Close loop poles of the desired system


Fig- step response after compensator

OBJECTIVE 3: Design a controller for following transfer function to meet the given specifications.

1.5
G(S)= --------------------
s^2 + 14 s + 40.2
• Rise timeless than 0.5 sec
• Overshoot less than 10%
• Gain margin greater than 20dB
• Phase margin greater than 40◦

PROGRAM:

syms s
n=1.5; % Defining numerator
d=[1 14 40.2]; %Defining denomator
G=tf(n,d); % Defining transfer function
sisotool(G) % open sisotool window for designing controller
Plot without controller
Figure – Step response without controller

Figure:-Tuning Designing constrains

Desired result with compensator


Figure:-Desired System Bode Plot
Fig:-Desired system step response
ASSIGNMENT NO. 6

OBJECTIVE 1: Find resulting transfer function, step Response.

Solution:-

OBJECTIVE 2:- Find resulting transfer function, step Response

Solution:-
OBJECTIVE 3:- Find resulting transfer function, step Response
OBJECTIVE 4:- Find resulting transfer function’s Step Response

Solution:- Step response


OBJECTIVE 5:- Find resulting transfer function, step Response.
OBJECTIVE 6:- Convert transfer function to state space model representation and then
again in to transfer function. Y(s)/R(s) = (3s^2+5s+2)/(s^3+6s^2+14s+4).

PROGRAM:

[A,B,C,D]=tf2ss([3 5 2],[3 6 14 4])

A=

-2.0000 -4.6667 -1.3333


1.0000 0 0
0 1.0000 0

B=

1
0
0

C=

1.0000 1.6667 0.6667

D=

0
OBJECTIVE 7:- Compute state space transition matrix for a given system matrix at
time t = 0.2 sec [A]=[2 -4 -6;3 1 2;2 -3 4]

PROGRAM:

syms s % assuming complex frequency function s


a=[2 -4 -6;3 1 2;2 -3 4]; %defining matrix a
I=[1 0 0;0 1 0;0 0 1]; % Identity Matrix
b=s*I-a; %Finding state transition matrix
ilaplace(b) % inverse laplace obtaining command

ans =

[ dirac(t, 1) - 2*dirac(t), 4*dirac(t), 6*dirac(t)]


[ -3*dirac(t), dirac(t, 1) - dirac(t), -2*dirac(t)]
[ -2*dirac(t), 3*dirac(t), dirac(t, 1) - 4*dirac(t)]

You might also like