MATLAB Algebraic Transfer Functions

Figure 1   MATLAB generated Bode magnitude and phase plot for H(s).
Listed below is a screen capture of the MATLAB commands used to generate the Bode plot shown in Figure 1. The ZPK function allows the transfer function h(s), to be entered algebraically in to MATLAB.

>> s=zpk('s')


 >> h=0.01*s/(1+s/100)*(1+s/1e4)

0.0001 s (s+1e04)

 >> h=0.01*s/((1+s/100)*(1+s/1e4))

     10000 s
(s+100) (s+1e04)

 >> bode(h)
 >> grid

Note that the algebraic expression for h was entered twice. The first time

>> h = h=0.01*s/(1+s/100)*(1+s/1e4)
This did not produce the desired transfer function. Poles at 100 and at 1E04 were desired. Instead MATLAB interpreted the pole at 1E04 to be a zero.

MATLAB performs multiplication and divisions in the order they appear. It multiplied 0.01 by s, then divided by (1+s/100), then multiplied by (1+s/1E04). That resulted in the factor (1+s/1E04) being in the numerator.

Note that extra parentheses were added to ensure that (1+s/1E04) remainded in the denominator.

Precedence decribes the order MATLAB performes operations. All operations have their place in the order of precedence. The first operation performed is prenthesis, (), other operations such as power, ^, follow. Multiplication and division follow power. Addition and subtraction follow multiplication and division.

Be carefull of precedence. As demonstrated above, it can cause unexpected results. If you are unsure, add extra parentheses to ensure operations are performed as expected.