Learning‎ > ‎

## Preface

(Summary of Section 1.6)
We can perform analysis, design, and simulation.
Alternative way of solving control system problems

Tool we are using:
MATLAB and MATLAB Control Systems Toolbox, which expands MATLAB to include control system-specific commands. Also contains:
• LTI Viewer: allows measurements directly from time and frequency response curves
• SISO Design Tool: analysis and design tool
• Symbolic Math Toolbox: saves labor when making symbolic calculations in analysis and design

## Requirements

MATLAB Version 7
Control System Toolbox 8

## References

Appendix B: MATLAB/Control Systems Toolbox tutorials and code
Appendix C: Simulink tutorials and diagrams
Appendix D: MATLAB GUI tools, tutorials, and examples. LTI Viewer and SISO Design Tool
Appendix E: Symbolic Math Toolbox tutorials and code

ch*sp* : Symbolic Math Toolbox

Useful MATLAB Commands/Tips
[1] [2]

How to plot Ramp response
[1]

## Appendix B

Code is available in Control Systems Engineering Toolbox folder at Companion site and at MATLAB Central

To access m-files from MATLAB, either:
• Add file to the search path
• File->Set Path...
• Navigate 'Current Directory' window to the file location
To run m-files in MATLAB, either:
• Type the m-file name in the Command Window
• In the Current Directory window, right-click -> Run
To view m-files in Command Window, either:
• Enter:
• type <file name>
• help <file name>
• Double-click file in Current Window to bring up file in editor
To create m-files:
• Type code into a .m file

### Chapter 2

• Represent polynomials
• find roots of polynomials
• multiply polynomials
• partial-fraction expansion

#### ch2p1 - Bit strings, Comments, Numbers, Operators, Variables

Bit strings: text enclosed in apostrophes
Numbers: Just enter as-is
Arithmetic operators: Use proper operator such as +,*
Variables: Use left-hand argument and = sign

`abs(Q)`
Magnitude of complex number Q

`angle(Q)`
Angle of complex number Q

m-file:
`'(ch2p1)'                           % Display label.`
`'How are you?'                      % Display string.`
`-3.96                               % Display scalar number -3.96.`
`-4+7i                               % Display complex number -4+7i.`
`-5-6j                               % Display complex number -5-6j.`
`(-4+7i)+(-5-6i)                     % Add two complex numbers and ``display sum.`
`(-4+7j)*(-5-6j)                     % Multiply two complex numbers and`` display product.`
`M=5                                 % Assign 5 to M and display.`
`N=6                                 % Assign 6 to N and display.`
`P=M+N                               % Assign M+N to P and display.`
`Q=3+4j                              % Define complex number, Q.`
`MagQ=abs(Q)                         % Find magnitude of Q.`
`ThetaQ=(180/pi)*angle(Q)            % Find the angle of Q in degrees.`

output:
`ans =`

`(ch2p1)`

`ans =`

`How are you?`

`ans =`

`   -3.9600`

`ans =`

`  -4.0000 + 7.0000i`

`ans =`

`  -5.0000 - 6.0000i`

`ans =`

`  -9.0000 + 1.0000i`

`ans =`

`  62.0000 -11.0000i`

`M =`

`     5`

`N =`

`     6`

`P =`

`    11`

`Q =`

`   3.0000 + 4.0000i`

`MagQ =`

`     5`

`ThetaQ =`

`   53.1301`

Variables:

#### ch2p2 - Polynomials

Polynomials: Polynomials in s can be represented as row vectors containing coefficients
• spaces in between: row vector
• commas in between: column vector
m-file:
`P1=[1 7 -3 23]      %Store polynomial s^3 + 7s^2 -3s + 23`
`P2=[1,7,-3,23]      % column vector`

Output:
`P1 =`

`     1     7    -3    23`

`P2 =`

`     1     7    -3    23`

Variables:

#### ch2p3 - Semicolons

Ending commands with a semicolon supresses the display of results.

source:
`P3=[1 7 -3 23];     %Store polynomial s^3 + 7s^2 -3s + 23`
`                    %But don't display output`

#### ch2p4 - poly()

`poly(V)`
Represent a function from factored form to polynomial form

factored form: a row vector containing the roots of polynomial
• (s+2)(s+5)(s+6) -> `[-2 -5 -6]`
polynomial form: a row vector containing the coefficients of polynomial (same as ch2p2)

m-file:
`P3=poly([-2 -5 -6])                  % Store polynomial`
`                                     % (s+2)(s+5)(s+6) as P3 and `
`                                     % display the coefficients `

Output:
`P3 =`

`     1    13    52    60`

#### ch2p5 - roots()

`roots(V)`
Go from polynomial form to factored form
root of polynomial returned as a column vector

m-file:
`P4=[5 7 9 -3 2]                     % Form 5s^4+7s^3+9s^2-3s+2 and `
`                                    % display.    `
`rootsP4=roots(P4)                   % Find roots of 5s^4+7s^3+9s^2`
`                                    % -3s+2, `
`                                    % assign to rootsP4, and display.    `

output:
`P4 =`

`     5     7     9    -3     2`

`rootsP4 =`

`  -0.8951 + 1.2351i`
`  -0.8951 - 1.2351i`
`   0.1951 + 0.3659i`
`   0.1951 - 0.3659i`

#### ch2p6 - conv()

`conv(a,b)`
Multiply polynomials

`P5=conv([1 7 10 9],[1 -3 6 2 1])    % Form (s^3+7s^2+10s+9)(s^4-`
`                                    % 3s^3+6s^2+2s+1), assign to `
`                                    % P5, and display.`

output:
`P5 =`

`     1     4    -5    23    48    81    28     9`

#### ch2p7 - residue()

`[K, p, k] = residue(b, a)`

Partial-fraction expansion for F(s) = b(s)/a(s)
• K - residue
• p = roots of denominator
• k = direct quotient
• found by dividing polynomials prior to performing expansion??
m-file:
`% We expand F(s) = (7s^2+9s+12)/[s(s+7)(s^2+10s+100)]. `
`% Result: F(s) = [(0.2554 - 0.3382i)/(s+5.0000 - 8.6603i)] + [(0.2554 + 0.3382i)/(s+5.0000 + 8.6603i)] - [0.5280/(s+7)] +[ 0.0171/s].`

`numf=[7 9 12];                      % Define numerator of F(s).`
`denf=conv(poly([0 -7]),[1 10 100]);          `
`                                    % Define denominator of F(s).`
`[K,p,k]=residue(numf,denf)          % Find residues and assign to K; `
`                                    % find roots of denominator and `
`                                    % assign to p; find`
`                                    % constant and assign to k.`

output:
`K =`

`   0.2554 - 0.3382i`
`   0.2554 + 0.3382i`
`  -0.5280          `
`   0.0171          `

`p =`

`  -5.0000 + 8.6603i`
`  -5.0000 - 8.6603i`
`  -7.0000          `
`        0          `

`k =`

`     []`

#### ch2p8 - example (TODO)

example 2.3 (TODO)

#### ch2p9 - Creating Transfer functions - Using Vectors

Use row vectors in either polynomial form or factored form to create LTI object/transfer function.

Polynomial form
Transfer function F(s) = N(s) / D(s)

N(s) = row vector containing coefficients of the numerator
D(s) = row vector containing coefficients of the denominator

`F = tf(numf/denf)`

source:
`'Vector Method, Polynomial Form'    `
`                                    % Display label.`
`numf=150*[1 2 7]                    % Store 150(s^2+2s+7) in numf and `
`                                    % display.        `
`denf=[1 5 4 0]                      % Store s(s+1)(s+4) in denf and`
`                                    % display.        `
`'F(s)'                              % Display label.`
`F=tf(numf,denf)                     % Form F(s) and display.`
`clear                               % Clear previous variables from workspace.`

output:
`Vector Method, Polynomial Form`

`numf =`

`         150         300        1050`

`denf =`

`     1     5     4     0`

`ans =`

`F(s)`

` `
`Transfer function:`
`150 s^2 + 300 s + 1050`
`----------------------`
`  s^3 + 5 s^2 + 4 s`

Factored form
Transfer function G(s) = K * N(s) / D(s)

N(s) = row vector containing roots of the numerator
D(s) = row vector containing roots of the denominator

`G = zpk(numg,deng,K)`
• zpk stands for zeros, poles, and gain
source:
`'Vector Method, Factored Form'      % Display label.`
`numg=[-2 -4]                        % Store (s+2)(s+4) in numg and `
`                                    % display.`
`deng=[-7 -8 -9]                     % Store (s+7)(s+8)(s+9) in deng and `
`                                    % display.`
`K=20                                % Define K.`
`'G(s)'                              % Display label.`
`G=zpk(numg,deng,K)                  % Form G(s) and display.`
`clear                               % Clear previous variables from workspace.`

output:
`Vector Method, Factored Form`

`numg =`

`    -2    -4`

`deng =`

`    -7    -8    -9`

`K =`

`    20`

`ans =`

`G(s)`

` `
`Zero/pole/gain:`
` 20 (s+2) (s+4)`
`-----------------`
`(s+7) (s+8) (s+9)`

#### ch2p9 - Creating Transfer functions - Using Rational Expression in s Method

Type the transfer function the same way we write it

Polynomial form

Create a symbolic ??? (TODO). Define 's' as an object
`s = tf('s')`

Enter F(s) similar to typing it on a computer

source:
`'Rational Expression Method, Polynomial Form'        `
`                                    % Display label.`
`s=tf('s')                           % Define 's' as an LTI object in `
`                                    % polynomial form.`
`F=150*(s^2+2*s+7)/[s*(s^2+5*s+4)]   `
`                                    % Form F(s) as an LTI transfer`
`                                    % function in polynomial form.`
`G=20*(s+2)*(s+4)/[(s+7)*(s+8)*(s+9)]                `
`                                    % Form G(s) as an LTI transfer`
`                                    % function in polynomial form.`
`clear                               % Clear previous variables from `
`                                    % workspace.`

output:
`Rational Expression Method, Polynomial Form`

` `
`Transfer function:`
`s`
` `
` `
`Transfer function:`
`150 s^2 + 300 s + 1050`
`----------------------`
`  s^3 + 5 s^2 + 4 s`
` `
` `
`Transfer function:`
`   20 s^2 + 120 s + 160`
`--------------------------`
`s^3 + 24 s^2 + 191 s + 504`
` `

Factored form

To create a transfer function in factored form instead:
`s = zpk('s')`

source:
`'Rational Expression Method, Factored Form'        `
`                                    % Display label.`
`s=zpk('s')                          % Define 's' as an LTI object `
`                                    % in factored form.`
`F=150*(s^2+2*s+7)/[s*(s^2+5*s+4)]   `
`                                    % Form F(s)as an LTI transfer`
`                                    % function in factored form.`
`G=20*(s+2)*(s+4)/[(s+7)*(s+8)*(s+9)]`
`                                    % Form G(s) as an LTI transfer `
`                                    % function in factored form.`

output:
`Rational Expression Method, Factored Form`

` `
`Zero/pole/gain:`
`s`
` `
` `
`Zero/pole/gain:`
`150 (s^2 + 2s + 7)`
`------------------`
`  s (s+1) (s+4)`
` `
` `
`Zero/pole/gain:`
` 20 (s+2) (s+4)`
`-----------------`
`(s+7) (s+8) (s+9)`

#### ch2p10- Obtain values from Transfer functions - tf2zp(), zp2tf()

Obtain factors of numerator and denominator from numerator & denominator of transfer function in polynomial form

`[outNum, outDen] = tf2zp(numf, denf)`

source:
`'Coefficients for F(s)'             % Display label.`
`numftf=[10 40 60]                   % Form numerator of F(s) = `
`                                    % (10s^2+40s+60)/(s^3+4s^2+5s+7). `
`denftf=[1 4 5 7]                    % Form denominator of`
`                                    % F(s) = `
`                                    % (10s^2+40s+60)/(s^3+4s^2+5s+7).`
`'Roots for F(s)'                    % Display label.`
`[numfzp,denfzp]=tf2zp(numftf,denftf)    `

output:
`Coefficients for F(s)`

`numftf =`

`    10    40    60`

`denftf =`

`     1     4     5     7`

`ans =`

`Roots for F(s)`

`numfzp =`

`  -2.0000 + 1.4142i`
`  -2.0000 - 1.4142i`

`denfzp =`

`  -3.1163          `
`  -0.4418 + 1.4321i`
`  -0.4418 - 1.4321i`

Obtain coefficients of numerator and denominator from transfer function in factored form

`[numgtf,dengtf]=zp2tf(numgzp',dengzp',K)`

source:
`'Roots for G(s)'                    % Display label.`
`numgzp=[-2 -4]                      % Form numerator of `
`K=10                                % G(s) = 10(s+2)(s+4)/[s(s+3)(s+5)].`
`dengzp=[0 -3 -5]                    % Form denominator of`
`                                    % G(s) = 10(s+2)(s+4)/[s(s+3)(s+5)].`
`'Coefficients for G(s)'             % Display label.`
`[numgtf,dengtf]=zp2tf(numgzp',dengzp',K)    `
`                                    % Convert G(s) to polynomial form.`

output:
`Roots for G(s)`

`numgzp =`

`    -2    -4`

`K =`

`    10`

`dengzp =`

`     0    -3    -5`

`ans =`

`Coefficients for G(s)`

`numgtf =`

`     0    10    60    80`

`dengtf =`

`     1     8    15     0`

Transpose: ' (TODO)

#### ch2p11- Convert Transfer functions between polynomial and factored form

use command `tf()` to convert a transfer function expressed in
factored form -> polynomial form

source:
`'Fzpk1(s)'                          % Display label.`
`Fzpk1=zpk([-2 -4],[0 -3 -5],10)     % Form Fzpk1(s)=`
`                                    % 10(s+2)(s+4)/[s(s+3)(s+5)].`
`'Ftf1'                              % Display label.`
`Ftf1=tf(Fzpk1)                      % Convert Fzpk1(s) to `
`                                    % coefficients form.`

output:
`ans =`

`Fzpk1(s)`

` `
`Zero/pole/gain:`
`10 (s+2) (s+4)`
`--------------`
`s (s+3) (s+5)`
` `

`ans =`

`Ftf1`

` `
`Transfer function:`
`10 s^2 + 60 s + 80`
`------------------`
`s^3 + 8 s^2 + 15 s`

use command `zpk()` to convert a transfer function expressed in
polynomial form -> factored form

source:
`'Ftf2'                              % Display label.`
`Ftf2=tf([10 40 60],[1 4 5 7])       % Form Ftf2(s)= `
`                                    % (10s^2+40s+60)/(s^3+4s^2+5s+7).`
`'Fzpk2'                             % Display label.`
`Fzpk2=zpk(Ftf2)                     % Convert Ftf2(s) to `
`                                    % factored form.`

output:
`Ftf2`

` `
`Transfer function:`
` 10 s^2 + 40 s + 60`
`---------------------`
`s^3 + 4 s^2 + 5 s + 7`
` `

`ans =`

`Fzpk2`

` `
`Zero/pole/gain:`
`        10 (s^2 + 4s + 6)`
`---------------------------------`
`(s+3.116) (s^2 + 0.8837s + 2.246)`

#### ch2p12- Plotting functions - plot()

Plot functions by specifying:
• variable and it's range
• functions
• plot characteristics
Specifying range and increment:
`'variable' = 'start point':'increment':'end point`'

Specifying functions:
`'function' = "function i.t.o variable defined earlier"`

Plotting:
`plot('variable', 'function', 'plot characteristics')`

we can also specify multiple functions on the same plot:
Adding 3 more parameters to the plot() for each function

source:
`'(ch2p12)'                % Display label.`
`t=0:0.01:10;            % Specify time range and increment.`
`f1=cos(5*t);            % Specify f1 to be cos(5t).`
`f2=sin(5*t);            % Specify f2 to be sin(5t)`
`plot(t,f1,'r',t,f2,'g')    % Plot f1 in red and f2 in green.`
`pause`

output:

#### ch2sp1 - Symbolic objects, Inverse Laplace transform

Any symbolic calculations require defining the symbolic objects. For example:
• Laplace transform variable s
• Time variable t
Defining symbolic objects allows us to write functions of the 'variable' as we would normally write it; no need to use vectors

Only variables/objects given as input to the program needs to be defined. Variable/object outputted by the program need not be defined

To define a 'variable' as symbolic object:
`syms 'variable'`To print functions on the command window as we would normally write it:
`pretty(F)`

To find inverse laplace transform of F(s):
`ilaplace(F)`

source:
`syms s                       % Construct symbolic object for `
`                             % Laplace variable 's'.`
`'Inverse Laplace transform'  % Display label.                     `
`F=2/[(s+1)*(s+2)^2];         % Define F(s) from Case 2 example.`
`'F(s) from Case 2'           % Display label.`
`pretty(F)                    % Pretty print F(s).`
`f=ilaplace(F);               % Find inverse Laplace transform.`
`'f(t) for Case 2'            % Display label.`
`pretty(f)                    % Pretty print f(t) for Case 2.`
`F=3/[s*(s^2+2*s+5)];         % Define F(s) from Case 3 example.`
`'F(s) for Case 3'            % Display label.`
`pretty(F)                    % Pretty print F(s) for Case 3.`
`f=ilaplace(F);               % Find inverse Laplace transform.`
`'f(t) for Case 3'            % Display label.`
`pretty(f)                    % Pretty print f(t) for Case 3.`

output:

`ans =`

`Inverse Laplace transform`

` `
`F =`
` `
`2/((s + 1)*(s + 2)^2)`
` `

`ans =`

`F(s) from Case 2`

` `
`         2 `
`  ---------------- `
`                 2 `
`  (s + 1) (s + 2)`
` `
`f =`
` `
`2/exp(t) - 2/exp(2*t) - (2*t)/exp(2*t)`
` `

`ans =`

`f(t) for Case 2`

` `
`    2         2         2 t `
`  ------ - -------- - -------- `
`  exp(t)   exp(2 t)   exp(2 t)`
` `
`F =`
` `
`3/(s*(s^2 + 2*s + 5))`
` `

`ans =`

`F(s) for Case 3`

` `
`         3 `
`  ---------------- `
`      2 `
`  s (s  + 2 s + 5)`
` `
`f =`
` `
`3/5 - (3*(cos(2*t) + sin(2*t)/2))/(5*exp(t))`
` `

`ans =`

`f(t) for Case 3`

` `
`        /            sin(2 t) \ `
`      3 | cos(2 t) + -------- | `
`  3     \               2     / `
`  - - ------------------------- `
`  5           5 exp(t)`
` `

#### ch2sp2 - Laplace transform

Find laplace transform, in partial fractions form, of time function. The time function should be defined in terms of symbolic object of time.
`F=laplace(f)`

source:
`syms t                       % Construct symbolic object for                              % time variable 't'.'Laplace transform'             % Display label.                     'f(t) from Case 2'           % Display label.f=2*exp(-t)-2*t*exp(-2*t)-2*exp(-2*t)                             % Define f(t) from Case 2 example.pretty(f)                    % Pretty print f(t) from Case 2 example.'F(s) for Case 2'            % Display label.F=laplace(f)                % Find Laplace transform.pretty(F)                    % Pretty print partial fractions of                             % F(s) for Case 2.`

output:
`f(t) from Case 2`

` `
`f =`
` `
`2/exp(t) - 2/exp(2*t) - (2*t)/exp(2*t)`
` `
` `
`    2         2         2 t `
`  ------ - -------- - -------- `
`  exp(t)   exp(2 t)   exp(2 t)`

`ans =`

`F(s) for Case 2`

` `
`F =`
` `
`2/(s + 1) - 2/(s + 2) - 2/(s + 2)^2`
` `
` `
`    2       2        2 `
`  ----- - ----- - -------- `
`  s + 1   s + 2          2 `
`                  (s + 2)`

Modify the form of resulting laplace transform:

Collect common coefficient terms of F
`collect(F)`

expands product of factors of F
`expand(F)`

factors F
`factor(F)`

finds simplest form of F with the least number of terms
`simple(F)`

simplifies F - combine the partial fractions
`simplify(F)`

source:
`F=simplify(F)               % Combine partial fractions.`
`pretty(F)                    % Pretty print combined partial fractions.`

output:
`F =`
` `
`2/((s + 1)*(s + 2)^2)`
` `
` `
`         2 `
`  ---------------- `
`                 2 `
`  (s + 1) (s + 2)`

Convert fractional symbolic terms into decimal terms with specified no.of decimal places
`vpa(expression, places)`

source:
`syms tf=3/5-3/5*exp(-t)*[cos(2*t)+(1/2)*sin(2*t)];         `
`                             % Define f(t) from Case 3 example.`
`pretty(f)                    % Pretty print f(t) for Case 3.`
`'F(s) for Case 3 - Symbolic fractions'`
`                             % Display label.`
`F=laplace(f);                % Find Laplace transform.`
`pretty(F)                    % % Pretty print partial fractions of`
`                             % F(s) for Case 3.`
`'F(s) for Case 3 - Decimal representation'`
`                             % Display label.`
`F=vpa(F,3);                  % Convert symbolic numerical fractions to`
`                             % 3-place decimal representation for F(s).`
`pretty(F)                    % Pretty print decimal representation.`

output:
`        /            sin(2 t) \ `
`      3 | cos(2 t) + -------- | `
`  3     \               2     / `
`  - - ------------------------- `
`  5           5 exp(t)`

`ans =`

`F(s) for Case 3 - Symbolic fractions`

` `
`   3       3 (s + 1)              3 `
`  --- - ---------------- - ---------------- `
`  5 s             2                  2 `
`        5 ((s + 1)  + 4)   5 ((s + 1)  + 4)`

`ans =`

`F(s) for Case 3 - Decimal representation`

` `
`  0.6         0.6           0.6 (s + 1.0) `
`  --- - ---------------- - ---------------- `
`   s             2                  2 `
`        (s + 1.0)  + 4.0   (s + 1.0)  + 4.0`

ch2sp3 - Input Transfer functions using Symbolic Math

Entering functions symbolically makes it easy to enter complicated transfer functions.

To convert the symbolic function to an LTI transfer function object
• extract the symbolic numerator and denominator
`[num,den]=numden(G)`
• convert the numerator and denominator to vectors
`numg=sym2poly(num)`
• form the LTI transfer function object using the above vectors
`tf(numg,deng)`
source:
`syms s                        % Construct symbolic object for `
`                              % frequency variable 's'.`
`G=54*(s+27)*(s^3+52*s^2+37*s+73)...`
`/(s*(s^4+872*s^3+437*s^2+89*s+65)*(s^2+79*s+36));`
`                              % Form symbolic G(s).`
`'Symbolic G(s)'               % Display label.`
`pretty(G)                     % Pretty print symbolic G(s).`
`[numg,deng]=numden(G);        % Extract symbolic numerator and denominator.`
`numg=sym2poly(numg);          % Form vector for numerator of G(s).`
`deng=sym2poly(deng);          % Form vector for denominator of G(s).`
`'LTI G(s) in Polynomial Form' % Display label.`
`Gtf=tf(numg,deng)             % Form and display LTI object for G(s) in`
`                              % polynomial form.`
`'LTI G(s) in Factored Form'   % Display label.                         `
`Gzpk=zpk(Gtf)                 % Convert G(s) to factored form.`

output:
`Symbolic G(s)`

` `
`                 3       2 `
`((54 s + 1458) (s  + 52 s  + 37 s + 73)) / `
` `
`        2                4        3 `
`   (s (s  + 79 s + 36) (s  + 872 s  + `
` `
`        2 `
`   437 s  + 89 s + 65))`

`ans =`

`LTI G(s) in Polynomial Form`

` `
`Transfer function:`
` `
`54 s^4 + 4266 s^3 + 77814 s^2 + 57888 s        `
`                                               `
`                                       + 106434`
`                                               `
`-----------------------------------------------`
`s^7 + 951 s^6 + 69361 s^5 + 66004 s^4          `
`                                               `
`                + 22828 s^3 + 8339 s^2 + 2340 s`
`                                               `
` `

`ans =`

`LTI G(s) in Factored Form`

` `
`Zero/pole/gain:`
` `
`  54 (s+51.31) (s+27) (s^2 + 0.6934s + 1.423)`
`-----------------------------------------------`
`s (s+871.5) (s+78.54) (s+0.558) (s+0.4584)     `
`                                               `
`                      (s^2 - 0.05668s + 0.1337)`
`                                               `
` `

#### Summary

List of commands learned

### Chapter 3

state-space representation stuff - SKIP - (TODO)

### Chapter 4

#### ch4p1 - calculate characteristics of second-order system

• damping ratio
• natural frequency
• percent overshoot
• settling time
• peak time
Just a bunch of arithmetic used. See example below.

source:
`'(ch4p1) Example 4.6'               % Display label.        `
`p1=[1 3+7*i];                       % Define polynomial containing first `
`                                    % pole.`
`p2=[1 3-7*i];                       % Define polynomial containing second `
`                                    % pole.`
`deng=conv(p1,p2);                   % Multiply the two polynomials to`
`                                    % find the 2nd order polynomial,`
`                                    % as^2+bs+c.`
`omegan=sqrt(deng(3)/deng(1))        % Calculate the natural frequency,`
`                                    % sqrt(c/a).`
`zeta=(deng(2)/deng(1))/(2*omegan)   % Calculate damping ratio,`
`                                    % ((b/a)/2*wn).`
`Ts=4/(zeta*omegan)                  % Calculate settling time, (4/z*wn).`
`Tp=pi/(omegan*sqrt(1-zeta^2))       % Calculate peak time, pi/wn*sqrt(1- `
`                                    % z^2).`
`pos=100*exp(-zeta*pi/sqrt(1-zeta^2))       `
`                                    % Calculate percent overshoot`
`                                    % (100*e^(z*pi/sqrt(1-z^2)).`

output:
`ans =`

`(ch4p1) Example 4.6`

`omegan =`

`    7.6158`

`zeta =`

`    0.3939`

`Ts =`

`    1.3333`

`Tp =`

`    0.4488`

`pos =`

`   26.0176`

#### ch2p2 - step responses - step()

To plot step responses of a LTI transfer function T(s)=num/den
`step(T)`

Multiple plots can be made using:
`step(T1, T2, ...)`

Information about the plots can be obtained by left-clicking on the curve
• curve's label
• coordinates of the point clicked
source:
`clf                                 % Clear graph.`
`numt1=[24.542];                     % Define numerator of T1.`
`dent1=[1 4 24.542];                 % Define denominator of T1.`
`'T1(s)'                             % Display label.`
`T1=tf(numt1,dent1)                  % Create and display T1(s).`
`step(T1)                            % Run a demonstration step response  `
`                                    % plot.`
`title('Test Run of T1(s)')          % Add title to graph.`

output:
`T1(s)`

` `
`Transfer function:`
`      24.54`
`-----------------`
`s^2 + 4 s + 24.54`

To bring up the options menu, right click away from the curve:
• system responses to be displayed
• response characteristics to be displayed
• peak response, etc
• grid, normalize, properties, etc

#### ch2p2 - step responses - Vectors from step()

The following is an alternative way of plotting step responses.

To create vectors containing the plot's points:
`[y,t] = step(T)`
• y = output vector
• t = time vector
To make a plot with these vectors:
`plot(t,y)`
• label the plot using `title('blah')`, `xlabel('blah')`, and `ylabel('blah')`
• To place text anywhere on the graph: `text(coordinateX, coordinateY, 'blah')`
To clear graph:
`clf`

The following code shows how to plot step responses of 3 transfer functions using step() and alternatively using vectors.

source: (Continuing from the above code)
`numt1=[24.542];                     % Define numerator of T1.`
`dent1=[1 4 24.542];                 % Define denominator of T1.`
`'T1(s)'                             % Display label.`
`T1=tf(numt1,dent1)                  % Create and display T1(s).`
`step(T1)                            % Run a demonstration step response  `
`                                    % plot.`
`title('Test Run of T1(s)')          % Add title to graph.`

`'Complete Run'                      % Display label.`
`[y1,t1]=step(T1);                   % Run step response of T1 and collect `
`                                    % points.`
`numt2=[245.42];                     % Define numerator of T2.`
`p1=[1 10];                          % Define (s+10) in denominator of T2.`
`p2=[1 4 24.542];                    % Define (s^2+4s+24.542) in `
`                                    % denominator of T2.`
`dent2=conv(p1,p2);                  % Multiply (s+10)(s^2+4s+24.542) for `
`                                    % denominator of T2.`
`'T2(s)'                             % Display label.`
`T2=tf(numt2,dent2)                  % Create and display T2.    `
`[y2,t2]=step(T2);                   % Run step response of T2 and collect `
`                                    % points.`
`numt3=[73.626];                     % Define numerator of T3.`
`p3=[1 3];                           % Define (s+3) in denominator of T3.`
`dent3=conv(p3,p2);                  % Multiply (s+3)(s^2+4s+24.542) for `
`                                    % denominator of T3.`
`'T3(s)'                             % Display label.`
`T3=tf(numt3,dent3)                  % Create and display T3.`
`[y3,t3]=step(T3);                   % Run step response of T3 and collect `
`                                    % points.`
`clf                                 % Clear graph.`
`plot(t1,y1,t2,y2,t3,y3)             % Plot acquired points with all three  `
`                                    % plots on one graph.`
`title('Step Responses of T1(s),T2(s),and T3(s)')`
`                                    % Add title to graph.`
`xlabel('Time(seconds)')             % Add time axis label.`
`ylabel('Normalized Response')       % Add response axis label.`
`text(0.7,0.7,'c3(t)')               % Label step response of T1.`
`text(0.7,1.1,'c2(t)')               % Label step response of T2.`
`text(0.5,1.3,'c1(t)')               % Label step response of T3.`

output:

Using the step() to plot T1,T2,T3:

source:
`step(T1,T2,T3)                      % Use alternate method of plotting step `
`                                    % responses.`
`title('Step Responses of T1(s),T2(s),and T3(s)')`
`                                    % Add title to graph.`

output:

TODO

#### ch2p4 - Example

TODO
Table lookup - interpl()

asdf
asdf