You are on page 1of 65

# MATLAB

- Matrix Laboratory

Contains base program plus tool boxes
(e. g. Control System Tool box)

To invoke matlab

type cd\matlab\bin
at DOS prompt

C:\ > cd\matlab\bin .

C:\MATLAB\BIN  Now type matlab .

Matlab prompt will appear as .

type demo on getting the prompt  demo .for demo.

.Now select your option & self learn.

g. for basic matlab commands. choose option 1 and enter .e. .

how to input a matrix A .

 A = [1 b 2 .4 b 6 ] .

The computer will respond as : A =  1 2 4 6 .

If you type  A = [ 1 b 2 . . 4 b 6 ] .

The screen output will be suppressed .

Multiply two polynomials in s p (s) = 2s + 1 q (s) = s + 4 2 3s + .

>> n = conv ( p. q ) n = 3 14 9 4 . >> q = [ 1 4 ] .>> p = [ 3 2 1 ].

5  value = polyval ( n.5 ) .Evaluate n (s) at s = . .

value = .66 .

G1 G2 2 s) G1 = 1 / (500 G2 = ( s +1 ) / ( s + 2 ) .

 dg1 = [ 500 0 0]. .To input a transfer function  ng1 = [1] .

 printsys ( ng1. dg1 ) num / den = .

1 500 s  2  .

 ng2 = [1 1] . .  dg2 = [ 1 2].

>> [ ng3.dg1.dg2 ) ng3 = 0 0 1 1 dg3= 500 1000 0 0 .ng2. dg3 ] = series ( ng1.

G1 + G2 + .

dg4 ] = parallel ( ng1.dg1.>> ng4 dg4 [ ng4.dg2 ) = 500 = 500 500 1000 1 0 2  0 .ng2.

+ - 1 s+1 .

. -1) . > > [nt. dt] = cloop (ng . .. >> dg = [1 1] . dg..>> ng = [1]. .

nt = 0 dt >> = 1 1 2 .

+ + 1 s+1 .

dg.[nt. 1 ) >> . dt ] = cloop ( ng.

nt = 0 1 0 dt = 1 > > .

+ - G H .

G = 1/ (500 2 s) H = (s + 1) / (s + 2) .

> > nh = [ 1 1].> > ng = [ 1 ]. > > dh = [ 1 2]. > > dg = [ 500 0 0 ]. .

dt ] = feedback ( ng. -1) . dh.> > [ nt. dg. nh.

nt = 0 0 1 2 dt = 500 1000 1 1 .

H2 _ R + _ G1 + G2 + + G3 G4 C H1 .

G1 = 1 / ( s + 10 ) >> ng1 = [1]. >> dg1 = [ 1 10 ]. .

.  dg2 = [ 1 1 ].G2 = 1 / ( s + 1 )  ng2 = [1] .

.  dg3 = [ 1 4 4 ].G3 = ( + 1 ) / 2 ( s +4s +4 ) 2 s  ng3 = [ 1 0 1 ].

.G4 = ( s +1 ) / ( s + 6 ) >> ng4 = [ 1 1 ]. >> dg4 = [1 6 ].

 dh1 = [1 2 ]. .H1 = ( s + 1 ) / ( s + 2 )  nh1 = [1 1] .

 dh2 = [ 1 ].H2 = 2  nh2 = [ 2 ]. .

H2 _ R + _ G1 + G2 + + G3 G4 C H1 .

Steps in reduction : • Move H2 ahead of G4 • Eliminate G3 G4 H1 loop .

• eliminate H 2 loop • eliminate the third loop .

H2 _ R + _ G1 + G2 + + G3 G4 C H1 .

• Move H2 ahead of G4 Find H2 / G4 .

>> n1 = conv ( nh2, dg4 ) ; >> d1 = conv ( dh2, ng4 ) ;

>> printsys (n1,d1)

num / den =
2s +12 -------s+1



eliminate G3 G4 H1 loop

H2 / G4 _ R + _ G1 + G2 + + G3 G4 C H1 .

dg4).ng4. dg3 . [ n2 . d2 ] = series (ng3 . .

nh1. d2. +1) . . dh1.>> [ n3. d3 ] = feedback (n2.

eliminate H2 loop .

H2 / G4 R + - - G1 + G2 C .

d4 ] = series ( ng2. .d3 ).>> [ n4.n3.dg2.

>> [n5.d1 ) . d5] = feedback ( n4.d4. n1. .

eliminate the third loop .

R + - G1 C .

ng1.>> [ n6.dg1) .d5. d6 ] = series (n5. .

-1 ). dt ] = cloop ( n6. d6. [ nt. .

dt ) .>> printsys ( nt.

num / den = s^5+4s^4+6s^3+6s^2+5s+2 --------------------------------------------------------------------12s^6 +205s^5 +1066s^4 + 2517s^3+ 3128s^2+2196s+712 .