Objective: Syntax: Pretty

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Linear Control System

LAB # 04
OBJECTIVE
To solve the signal flow graphs and find transfer function by using MATLAB & Masons Gain
Formula.

THEORY
1.

Syms: Short-cut for constructing symbolic objects


Syntax: syms

2.

Solve: The input to solve can be either symbolic expressions or strings. If eq is a


symbolic expression (x^2-2*x+1) or a string that does not contain an equal sign ('x^22*x+1'), then solve(eq) solves the equation eq=0 for its default variable (as determined by
findsym).
Syntax: solve

3.

Pretty:The pretty function prints symbolic output in a format that resembles


typeset mathematics. pretty(s)prettyprints the symbolic matrix S using the default line
width of 79.
pretty(s,n) prettyprints S using line width n instead of 79.
Syntax: pretty

4.

Transfer Function: Specifies the transfer function H(s) = s (Laplace variable).


You can then specify transfer functions directly as rational expressions in S or Z.
Syntax :< S= TF ('S')>

EXERCISE
Task 01:
For the given signal flow graph, find the value of A & B.

Fig 4.1
Sir Syed University of Engineering & Technology
Electronic Engineering Department

Linear Control System

Coding:
syms r e1 e2 e3 e4 g1 g2 g3 g4 c h1 h2 h3
v=solve('e1=r-(h1*e2)-(h3*e4)','e2=(g1*e1)+(c*g4)','e3=(g2*e2)(h2*e4)','e4=e3*g3','c=e4',e1,e2,e3,e4,c);
t.f=v.c/r;
pretty(t.f)

Result:
task4a
g1 g2 g3
-------------------------------------------------------g1 h1 + g3 h2 - g2 g3 g4 + g1 g2 g3 h3 + g1 g3 h1 h2 + 1

Task 02: Find C/R of the given signal flow graph


Fig 4.2

Coding:
syms a b
v=solve('a=3-(4*b)','b=(10*a)-8',a,b);
A=v.a;
pretty(A)
B=v.b;
pretty(B)
Sir Syed University of Engineering & Technology
Electronic Engineering Department

Linear Control System

Result:
task4b
A=
35/41
B=
22/41

Task 03:
Find C/R using Masons Gain Formula.

Fig 4.3

Coding:
syms g1 g2 g3 g4 g5 g6 h1 h2
m1=g1*g2*g3*g4*g5;
m2=g6*g4*g5;
l1=-(h1*g2);
l2=-(h2*g4);
del1=1;
del2=1-(l1);
del=1-(l1+l2)+(l1*l2);
t=((m1*del1)+(m2*del2))/del;
pretty(t)

Result:
task4c
Sir Syed University of Engineering & Technology
Electronic Engineering Department

Linear Control System


g4 g5 g6 (g2 h1 + 1) + g1 g2 g3 g4 g5
------------------------------------g2 h1 + g4 h2 + g2 g4 h1 h2 + 1

Conclusion:
In this lab we learn how to implement the masons gain formula of signal flow
graph and calculate the transfer function in matlab using syms, solve, pretty & transfer function
command

LAB ASSIGNMENT
1.

Find C/R of the given signal flow graph by using MATLAB and also by
hand written as you perform in theory.
Sir Syed University of Engineering & Technology
Electronic Engineering Department

Linear Control System

Fig 4.4

2.

Find transfer function of the given signal flow graph by using Masons gain formula.

Fig 4-5

Sir Syed University of Engineering & Technology


Electronic Engineering Department

You might also like