2.8.  APPLICATION OF MATLAB TO CONTROL SYSTEMS [6]

At this juncture of the presentation, we can show that partial-fraction expansion can also be accomplished with a simple command from MATLAB. An important feature of this book is that most of the solutions shown in this book were generated using the commercially available software package called MATLAB which is available from the Math Works, Inc. The Modern Control System Theory and Design (MCSTD) Toolbox, which complements this book, and the M-files that were used to develop these solutions can be retrieved free from The Mathworks, Inc. anonymous FTP server at ftp://ftp.mathworks.com/pub/books/shinners. These M-files are the MCSTD Toolbox and were used to develop the graphical figures and problem solutions in this book. In this manner, the user of this book has available a toolbox of features/utilities created to enhance The Mathworks’ Control System Toolbox, and the computer-generated solutions to the problems in this book. The Modern Control System Theory and Design Toolbox runs equally well with The Student Edition of MATLAB (authored by The Mathworks, Inc., and published by Prentice-Hall, Englewood Cliffs, NJ), as well as with or without the professional versions of MATLAB (with or without The MathWorks’ Control System, Simulink, Nonlinear, and the Symbolic Toolboxes).

  • MATLAB, an abbreviation for MATrix LABoratory, is a matrix-based system used for engineering calculations which has progressed to become the language used by most control-system engineers worldwide. This section focuses attention on the required background needed for designing control systems with MATLAB. MATLAB is a very useful language which operates interactively with the user, and will respond to all of the user’s attempts at conversation. It offers a variety of graphic output displays useful to control-system engineers such as system block diagram development (Simulink required), linear, log, semilog, polar, and contour plots. It is envisioned that this section will serve as a supplement to Reference 6, and enable students, professors, and practicing engineers to quickly learn the basics needed to use MATLAB with its associated toolboxes and the Modern Control System Theory and Design Toolbox.

This integrated textbook and software learning package is self-contained, and is designed for undergraduate courses on control systems and for the practicing engineer. This toolbox (software) contains extensive new features/utilities created to enhance MATLAB and several of The Math Works’ toolboxes. Since this integrated learning package and the MATLAB software is self-contained, it is not necessary to purchase additional books/material to learn how to use MATLAB with this textbook.

The software contained in the Modern Control System Theory and Design Toolbox contains the following features that makes this book self-contained for use with MATLAB:

  • A Tutorial File has been created that contains the essentials necessary to understand and effectively utilize the MATLAB interface. This tutorial file aids the user in understanding the MATLAB interface where most other books require additional books for full comprehension. Features of this file are as follows:
    • MATLAB installation assistance
    • MATLAB performance improvement suggestions
    • MATLAB fundamentals
    • Understanding notations used by MATLAB
    • Control analysis using MATLAB
    • Modern Control System Theory and Design Toolbox use with MATLAB
  • A Demonstration m-file gives the users a feel for the various utilities included in the Modern Control System Theory and Design Toolbox. Included are the following:
    • General purpose utilities
    • Linear, frequency domain, Bode diagrams (used starting in Chapter 6)
    • Linear, frequency domain, Nichols charts (used starting in Chapter 6)
    • Linear, frequency domain, Root locus (used starting in Chapter 6)
    • Nonlinear, frequency domain, Describing function (used in Chapter 5 of the accompanying volume)
    • Linear, time domain
    • Conversions between discrete time domain and continuous time systems (used in Chapter 4 of the accompanying volume)

    This demonstration helps the user learn how to use the MATLAB package easily with the Modern Control System Theory and Design Toolbox and, with the tutorial, makes this integrated package self-contained.

  • Online HELP is available for all Modern Control System Theory and Design Toolbox utilities. Additionally, the “lookfor” command is fully supported in the online help for each Modern Control System Theory and Design Toolbox utility.
  • A Synopsis File reviews and highlights the features of each chapter in Modern Control System Theory and Design in a concise manner which is helpful in guiding the professor on subjects to emphasize, and to the student and practicing engineer for reviewing and remembering important aspects of the coverage.
  • The software is compatible with all editions the The Student Edition of MATLAB [31] and the Professional Versions of MATLAB [6], and it is compatible with The Math Works’ following software packages:
    • Control System Toolbox
    • Simulink Toolbox
    • Nonlinear Toolbox
    • Symbolic Toolbox

      I have attempted to make the presentation of MATLAB easy reading for the reader about to learn and use MATLAB. Most of this material can be read with little or no hands-on practice while getting a full grasp of most of the MATLAB capabilities.

A.  First Time Usage—Software For Engineering*

This section deals with the software. It does assume that you already have an understanding of the theoretical principals of the topics about to be presented. Any software that you may use now, or any time in the future, is only as good as your comprehension of the topics, and your ability to interpret the results presented to you by the computer. This cannot be stressed enough, because misinterpreted results due to whatever cause (incorrect inputs, computer round-offs, misinterpreted printouts, faulty programming code, etc.) can lead to any number of problems, depending on what you are doing. Computer literate people are all too aware of this, and have even given this a name: GIGO (garbage-in/garbage out).

With the advent of modern computers, engineers (as well as many other technical professionals) have had available a tool that can help them do their jobs quicker, more accurately, presentably, etc. The main question is what software are you going to use? Programming it all yourself is cumbersome, time-consuming, must be customized for each application, requires extensive understanding of all the topics encompassed, and on top of it all, is possibly ridden with errors. However, existing software packages have most of the features you require at a simple-to-use level (“user-friendly”).

The major problem that most people have is which software package to buy! The correct answer has to depend on your current needs, and your expected near-term future needs. Far future needs probably should not be addressed due to the continually evolving computer software and hardware world, and should be re-evaluated when you get there. Some topics to consider are:

  1. Ease of learning/use (user-friendly)
  2. Analytic capability
  3. Graphic capability
  4. Expandability/modularity
  5. Technical support/support groups
  6. Hardware requirements
  7. Price

Considering that this section is primarily prepared for a course in which it is beneficial for the student to own their own software (maximizing-capability/minimizing-costs), versus having a classroom licence (which usually ends up being a onetime experience), I suggest using “The Student Edition of MATLAB” by the MathWorks, Inc. It includes Software, Manual, User Groups, etc., and has most of the essentials that assist in learning a wide variety of topics at a very modest price.*

The Student Edition of MATLAB package gives you extensive mathematical/analytical/graphical capabilities, as well as a “taste” of two of the different professional-level toolboxes (Signal Toolbox and Control Toolbox) that they combine to call the “Signals and Systems Toolbox” (quite adequate for classroom training purposes of both topics). This is adequate for you to realize many control-theory applications, the programming potential of MATLAB, and the ease of dealing with toolbox addons (conceptually and mathematically). Another item of interest to all, is that there are available “FREE” toolboxes to all who desire. In their newsletters (that they willingly send to registered users) they list textbooks that use MATLAB and/or have toolboxes associated with the books. To top it off, they maintain a MATLAB User Group software library (nicknamed MUG) that contains all past newsletters, and FREE User software, as well as examples, and other useful information, available at no charge to you.

B.  First Time Usage—MATLAB Installation

Installation is quite straightforward, just a little time-consuming. This step-by-step installation procedure focuses on the IBM (or compatible) PC. However, there are additional instructions in the MCSTD Toolbox which apply equally as well to Macintosh and UNIX users. The user will need some basic knowledge of DOS and the system that you are working on. Certain typos in the first printing of The Student Edition of MATLAB for the IBM PC have been identified (subsequently corrected in later printings), and it is suggested that you correct them prior to reading and installing MATLAB:

  1. p. 16: “three or more 360K” should read “two 360K”
  2. p. 26: “MATLABGEO” should read “MATLABGEO”

Now simply follow the directions in Chapter 4. Once completed, you are ready to start using the student version of MATLAB. You may want to read the section on MATLAB fundamentals before trying to use MATLAB, but definitely read the following first.

If you have followed the installation section of MATLAB, all you have to do to start using MATLAB, is to type “MATLAB” and hit enter at the DOS prompt.

After a moment to load, you should see the MATLAB copyright message on the top of the screen, followed by the line “HELP, DEMO, and INFO are available” (if proper installation has occurred). If this much does not come up whenever you activate MATLAB, something has gone wrong.

If you encounter any difficulties with the package:

  1. Re-read the appropriate chapters in the textbook.
  2. Check for obvious typographical errors.
  3. For the Student Edition, consult the instructor (who has the available technical support). For the professional version, consult The MathWorks.

The first time (and only the first time) that you activate MATLAB, it will prompt you for registration information (serial number and your name) following its normal messages. The MATLAB book does not tell you anything about this step because it is a leftover feature from the professional version not described in any (student version or professional version) of their manuals (it is explained with a separate letter attached to the professional version). It is a formality, so that you can identify your copy of MATLAB without having to pull out your original diskettes when calling for technical support. Fill it in by answering the prompts that come on the screen. I do suggest entering your name, if nothing else but to personalize this copy as yours.

To add additional toolboxes to MATLAB, merely follow the directions on the bottom of page 26 (as if you are adding a library of your own). For installing the FREE Modern Control System Theory and Design Toolbox (henceforth called the MCSTD toolbox), proceed as follows:

  1. “MDMATLABMCSTD,” I chose the name MCSTD as an abbreviation of the name.
  2. “COPY A:TOOLBOXMATLABMCSTD,” copy the toolbox part of the MCSTD diskette.
  3. “EDLINMATLABBINMATLAB.BAT,” update the file to reflect the new toolbox. In MATLAB version 4.0, the file “MATLABRC.M” must be updated, the “SET MATLABPATH = ” has now got to have “;MATLABMCSTD” appended to it.
  4. The toolbox is fully installed and ready to be used in MATLAB.

The problems, figures, Fortran and demo directories that come with that toolbox are non-essentials (but give a nice demo of the MCSTD features and a variety of worked examples from this book). They can be installed in a similar manner to the above. The readme.m, contents.m, tutorial, and synopsis files should be printed as reference material.

C.  First Time Usage—Performance Tuning MATLAB

I wish to provide to the reader some of the things that I have learned in the proper use of MATLAB. For those of you who will spend hours at a time using MATLAB (student or professional version), this material will greatly benefit you. These are the suggestions that I make to my fellow colleagues using MATLAB, for significantly improving performance at an insignificant cost!

The first thing you notice when starting MATLAB, is how long it takes to start before you can type. Those of you with sharp eyes and/or minds might even notice a lot of hard disk activity occurring during this time. This is because MATLAB is an interpreter. That means for every command that you give, it must read the file with that command in it (and similarly the same for every command called inside the original command). With that in mind (and the fact that you can’t change this), the faster the drive that has all these commands on them, the faster your performance.

The limiting factors for your choice, as you will see, is available computer memory and/or your desire to try something different. Buying a new and better drive is overkill and may not give you peak performance. Software that improves your current drive’s speed is a step in the right direction; however, creating a drive out of computer memory (which is the fastest possible drive for your machine) is the ideal choice. The super-intelligent among you will even use a combination of these techniques (as I am about to explain). I have seen speed factor improvements of 3 to 15 times using these techniques.

With the advantages come the disadvantages (and I feel I should point them out before going any farther). When creating memory drives, as the computer is turned off, all information on that drive is lost. My solution is to copy the standard toolboxes and software to that drive when I am going to use it (requires a short additional length of time), and keep my personal routines and data on my hard disk (the best of both worlds). Also, most PCs have limited memory which you use sparingly. My solution is: if you don’t mind the speed, stick with what you have. Otherwise, merely buy and install more memory (the appropriate type: expanded or extended) for your computer.

The amount of memory that you desire for your memory drive (henceforth called ramdrive) depends on how much software you want to put there, the more you put the faster you go. Demo routines with their data do not have to be kept on the ramdrive after you have become familiar with them. But for now, you can add up the sizes of the files you want to move (add 10 percent for blank space) to see how big this ramdrive should be.

The commands that add this ramdrive to your system (provided that the memory is already there) are either vdisk, ramdrive (in DOS), or whatever appropriate software came with the memory that you purchased. An example of my computer setup (using DOS version 5.00 with high memory; your machine may different) for The Student Edition of MATLAB is:

  1. Adding “DEVICE = C:DOSRAMDRIVE.SYS 2000/E” to the file “C:CONFIG.SYS” makes a 2000KB (2MB) ramdrive. Most ramdrives make you add one or more lines to the file “C:CONFIG.SYS.” When your computer is rebooted, the ramdrive should be available for use.
  2. Adding “DEVICE = C:DOSSMARTDRV.SYS” to the file “C:CONFIG.SYS,” adds disk caching upon reboot.
  3. Adding “FASTOPEN C:” to the file “C:AUTOEXEC.BAT,” improves file access performance for that drive.

In step one, you may choose an appropriate size for your specific needs. I chose 2MB because it is adequate to hold all of Student Edition of MATLAB and the complete MCSTD Toolbox, serving my purpose quite well. You may choose not to put all that on your ramdrive, but only the parts that you are going to use (such as no demo files, compiler linking files, example files, etc.). On the other hand, you may have other toolboxes that you want to put on this ramdrive. This is a choice that you must make.

Now that you have your ramdrive set up (all changes have been made and you have rebooted), you want to take advantage of these changes. I will use “F:” as the letter of the ramdrive created—change according to your individual system. Your file that starts MATLAB up (“C:MATLABBINMATLAB.BAT”) has to reflect these changes. This is how I suggest altering that file:

  1. Add to the top of the file a line for each directory that you want to copy which copies that directory from your hard drive to your ramdrive. One example is “XCOPY C:MATLABMATLAB F:MATLABMATLAB”. This would copy MATLAB from your hard disk C: to your ramdrive F:.
  2. Alter the “SET MATLABPATH = ” line by including the drive letter where the directory exists for each directory listed (you may mix between hard disk and ramdrive as you choose). In MATLAB version 4.0, the MATLABPATH is set in the file “MATLABRC.M”.

The next performance suggestion concerns improving the speed of shelling to DOS with the MATLAB “!” command. If the computer uses the file “COMMAND.COM” from a ramdrive, it can load and execute the “!” command faster. Not only MATLAB will benefit from this tip, but also any program that shells to DOS. Further DOS performance tips I leave for the experts to suggest (but I do like this one in particular). This is my suggestion for altering the file “C:AUTOEXEC.BAT”:

  1. Add “COPY C:COMMAND.COM F:” to the bottom of this file.
  2. Add “SET COMSPEC = F:COMMAND.COM” following the copy line. This tells DOS to use that file when shelling to DOS.

The last performance suggestion, as mentioned earlier, concerns demo files which take room but also make the computer search for each MATLAB command a little wider (since it checks all file names in the MATLABPATH until the file is found). I do not like losing anything, so what I do is move the demos/examples of each toolbox to separate directories (as I have already done in the MCSTD toolbox). This way I can always add the demos/examples to the MATLABPATH in the MATLAB.BAT file. Personally, I like to do as little as possible, and just create a copy of the MATLAB.BAT file (I call MATLABD.BAT) with those changes made to it. Also, I do not copy the demos/examples to the ramdrive (which would reduce the room on the ramdrive as well) unless I want them (as in MATLABD.BAT).

D.  First Time Usage—MATLAB Fundamental Concepts

MATLAB is a very simple, but efficient, interpreter (versus compiler). This allows you to type in a line and have it execute immediately. The tremendous advantage is that you do not have to re-compile your program (as you would in Fortran, Pascal, or C) for every change you make before re-executing the code, as well as the ability to view the values of the variables without adding debugging write statements to your program. MATLAB does include an interface so that you can execute your Fortran or C code from inside MATLAB (see MATLAB manual section on MEX files). Like any other language, it has a small subset of commands (statements), from which other more sophisticated commands are developed by the users. There are four fundamental items in MATLAB: variables, functions, programming code and algebraic operators.

Variables, in MATLAB, are all treated as matrices. Text strings (which are stored as matrices), however, are automatically given a special attribute, so that the ASCII text value is printed (not the numeric value).

Functions in MATLAB operate slightly differently than most programming languages (with the possible exception of C + +). Most MATLAB functions take none, one or more variables as parameters (within the parenthesis), and return none, one, or more variables as a result. An unusual aspect of this is that a single function can be used many different ways depending on how many parameters are being passed in, the type of data being passed in, and how many parameters are being retrieved.

Programming code, in MATLAB, is mainly for control flow, directory manipulation, data storage, and debugging purposes. Like most languages, this includes: if, else, end, for, while, ... etc. These will be discussed in more detail later in this text.

Algebraic operators, in MATLAB, are very similar to the math operators that you are used to, with only a few minor exceptions. The main consideration to be taken when using them is that they are (almost all) matrix math operators. If you want to use scalar mathematics, you must take care to use the scalar versions of the algebraic operators.

Another topic that should be mentioned in this section, is the concept of toolboxes. A toolbox, in MATLAB, is a collection of functions/utilities that work together on a specific topic (i.e., signal processing, control processing, system identification toolbox, ...) so that it (hopefully) meets all your needs on this topic, and you do not need to program any functions for your own needs. As your skills expand into other areas of expertise, there are other toolboxes (the MATLAB toolbox list is always growing) available for (in the professional world) a reasonable cost (versus you programming-debugging-testing your own code for each specific need). The MathWorks’ desire to express this highly important fact has lead them to include the “Signal and Systems” toolbox with their student version. This toolbox gives the user a taste of the professional versions of the Signal and Systems Toolbox and the Control-System toolbox. A more detailed discussion on these and other toolboxes will follow later.

E.  First Time Usage—Matrix Representations

Every variable of any sort in MATLAB is a matrix. The approach is to represent a wide variety of items as matrices. Once certain conventions (of which MATLAB has many predefined) are agreed upon, all that remains is to learn how to use them. All the types about to be described here have values which are either real or complex.

Scalar values start very simply, represented as a 1 × 1 matrix. They can take on any double precision value that the computer can represent, including some unusual ones: Infinity (Inf) and Not-A-Number (NaN).

Inf represents a number the representation of which is beyond the computer’s ability. Almost any mathematical operation dealing with such a number yields the value Inf, as should be expected.

The use of NaN is difficult to illustrate; consider a set of data with one value in it that is totally absurd. If you use that value in your data set, your analysis results will be totally corrupted. Instead of removing that data from your set (which sometimes cannot be done) it would be nice to say that value is Not really a valid Number, hence NaN. Now we can agree to check for this value in our analysis routines, which is already done in many MATLAB routines.

Vector values become a little more sophisticated, represented as a 1 × N matrix or a N × 1 matrix (N being the length of the vector). The distinction between the two representations is used by MATLAB, and will be examined later. The typical uses of a vector are as a set of data, polynomial representations, etc. These uses will become more apparent to you as you practice with the topics presented later.

Matrix values are straightforward, as they represent a matrix. In MATLAB version 4.0, matrices have an added feature of being “sparse.” Sparse matrix technology is a method for storing a large matrix filled with mostly zeros, in a much smaller storage space. This can aid in speed when dealing with these matrices. This feature does not change the features of a matrix, just the physical storage and speed of execution when used. Some typical matrix representation examples are sets of data samples, transition matrices, covariance matrices, etc. Once again, these uses will become more apparent to you as you practice with the topics presented later.

Strings are a little more confusing to understand. They are stored, like vectors, as a 1 × N matrix. The difference between strings and vectors is that strings are given a special attribute (automatically set by MATLAB) so that they will be displayed properly on the screen. A non-vital detail (trivial and for reference purposes only) is that each letter in a string is stored as the numeric value of its ASCII representation.

F.  First Time Usage—MATLAB Fundamentals

The MATLAB prompt that is listed/described in the manual is the “≫”. At this prompt you will begin to learn how to use MATLAB. This practice session is created to give you the idea of how exit, find help, and inquire about variables in MATLAB.

MATLAB, like most modern software packages, tries to make the commands it uses very simple and logical. Most commands are like their English counterparts, making (hopefully) the commands simple for everyone to understand. One important fact that should be stated now is that MATLAB is case sensitive (this means that entering things in upper case is different than entering things in lower case). All commands that are to be entered in the following practice session should be in lower case unless specifically stated. After each command has been entered, to start the execution of the command press Enter or Return (this shall be assumed with each of the following commands, unless otherwise stated).

The first thing that any software should teach is how to exit the software and get back to your operating system (DOS). There are two wasy to do this: “exit” or “quit”. Both are good examples of English-like commands. A good idea before exiting any software program is to save your work, but for now we shall not do this (especially since we have done no work, and you have not been shown how to save as of yet). After executing either of these commands, if you choose to continue using MATLAB, you must start MATLAB up because you have been returned to DOS.

The next thing that we are going to do is to “demo” some of the MATLAB features. Hopefully, you will have guessed that the command to do this is “demo”, and you would be right. An extensive demo has been prepared by MATLAB, showing you a wide variety of its capabilities. You should take the time to try a few (or all) of these demos at your leisure.

The “help” feature of MATLAB is very useful to the user. This was designed so that you do not have to pull out the MATLAB manual (or toolbox manual(s)) in order to be able to understand the various commands currently available to you. There are several different ways to use the help command, depending on the version of MATLAB that you possess.

By typing “help” by itself, you will get either a list of all installed toolboxes (version 4.0 or later) or a list of all the currently available commands organized on different screen according to the toolboxes that you have installed (prior to version 4.0). As you add additional toolboxes to MATLAB, each toolbox will have its own screen listing the commands available in that toolbox. This is a nice feature which helps the individual think in a modular fashion when going to the professional world.

In version 4.0 or later, typing “help” followed by a space and the installed toolbox directory name, will list the commands in the toolbox with a oneline explanation of their functions (e.g., “help matlab”).

Additionally, by typing “help” followed by a space and any listed command (in the manual or on the help screens), you will get an explanation of the command and how to use it (e.g., “help quit”).

It is highly recommended that you review The Student Edition of MATLAB. I suggest getting some hands on practice while reading it. Functions worth reading about (or at least glancing at the help screens) are:

  1. “!” allows you to execute DOS commands (from inside the MATLAB), without having to quit your MATLAB session (called shelling to DOS). When the DOS command that issues following the “!” has completed, you are returned to MATLAB without losing any of your MATLAB session.

    TSR warning: Do not use the “!” to run any TSR program. Start all TSR programs prior to entering MATLAB. TSRs take memory to add themselves to your environment (DOS). MATLAB is not aware of this memory usage, and will consequently use the memory, at some point in time, clobbering software and probably corrupting MATLAB and/or DOS (in memory). Do not be fooled if you do not see this happen, you may have been lucky in one of several ways this time. This time MATLAB may not have used the memory. This time what it clobbered may not have had any effect. Or you simply did not realize that the corrupted system is now returning corrupted results (MATLAB and/or DOS)!

  2. “load“ allows you to get data that has been stored. Two forms of data currently can be loaded: their own special form (called MAT files) and ASCII files that contain one numeric matrix (any size allowed) in it. This is useful to get data into MATLAB from other software packages.
  3. “save” is the counterpart to load. This allows you to save data for future use. Like load, it saves as a MAT file or as an ASCII file (upon request). This is useful if you intend to export data to other programs after processing them in MATLAB.
  4. “plot” is your first step into MATLAB’s graphic world. There are too many different graphic commands to list, each with accompanying support functions. But as you may have guessed, “plot” plots data on the screen.

    Getting printed copies of the graphs is done in several different ways (see Apendix C in The Student Edition manual): using a graphic screen dump to the printer utility (printed quality is only as good as the screen resolution), using the “meta” command with their “GPP” software (professional MATLAB prior to version 4.0 or later), and using the print command or print menu (professional MATLAB version 4.0 or later). Since this is for the student version, I shall discuss the screen dump utility.

    DOS and MATLAB both come with screen dump TSRs (see prior TSR warning). If you intend to print any plots, you should load either one of these utilities prior to starting up MATLAB! The DOS utility is called “GRAPHICS.” The MATLAB utility is “EGAEPSON” for Epson compatible printers, or “EGALASER” for laserjet compatible printers. If you have problems printing and have a VGA monitor, a suggestion is to restart MATLAB in the EGA mode.

Most functions are recognizable by their name and one-line descriptions. In The Student Edition manual (the only book that I reference by pages), you will find this section on pp. 185194.

G.  Control Systems—Data Representation

I will now show how to represent real systems as mathematical models. Any type of control system is going to be represented as matrices in MATLAB. The trick is to become fluent with their usage (which only really comes with practice). Each of the following subsections will make sense as you have been properly introduced to their topics by your instructor.

First and foremost, in most control-theory classes, is the transfer function representation of a system. This is where a system is represented by a series of polynomials, usually organized (as in most control-theory textbooks) as:

Image

Here, a single-input/single-output (SISO) transfer function can be represented as two polynomials of decreasing powers (numerator polynomial divided by a demoninator polynomial). In MATLAB, a polynomial (numerator, denominator, or other) is represented as a row vector (1 × N matrix) containing the scale factors for each of the sequentially decreasing powers of s. This is a very important point to comprehend before reading the following examples:

  1. “17s5 + 23s3 + 8s2 + 6” converts to “[17 0 23 8 0 6]”. The highest power of s is five, so there will be six numbers in this vector (s-powers 5 to 0). Powers of s that are not there have scale factors of zero (they hold the s-power sequence and are NOT to be forgotten).
  2. “5 + 12s + 4s3 + 3” converts to ”[4 0 12 8]”. If you cannot visually see this, then the best thing you can do for yourself is to rewrite the polynomial in “decreasing powers” of s as: “4s3 + 0s2 + 12s1 + (5 + 3)s0” or more simply “4s3 + 12s + 8.” You should now be able to see how to do this.

Next is the zero-pole-gain method that is similar to the transfer function in that the two methods represent the same equations, the equations have merely been manipulated into a different form. The difference is though that the polynomials have been factored into their roots, and “k” is the gain that makes the equations equal (namely the highest s-power numerator scale-factor divided by the highest s-power denominator scale-factor). This representation of the system is:

Image

Here, a single-input/single-output (SISO) system (called the zero-pole-gain function) can be represented as two sets of roots (numerator and denominator) and a gain factor. When any of the numerator roots values goes to zero, the overall function value goes to zero; hence the numerator roots are called “Zeros.” When any of the denominator root values goes to zero, the overall function value goes to infinity; hence, the donominator roots are called “Poles.”

In MATLAB, a set of polynomial roots (numerator, denominator or other) is represented as a column vector (N × 1 matrix) with each element representing one of these roots. The Student Edition attempts to show this “simple” transformation with one example followed by one example of the zero-pole-gain method. A few examples follow to challenge your understanding of “polynomial root” representation:

  1. “(s − 3)(s − 4.5)(s + 100)” converts to “[3; 4.5; − 100]”. By now you should recognize the semicolon from MATLAB as meaning (among other things) a new line (new row). This makes the matrix listed above become a 3 rows by 1 column matrix (column matrix, three in length).
  2. “(s − 2)(s − 500)(s − 30)” converts to “[500 ; 30 ; 2]”. Your first guess would probably be different ([2 ; 500 ; 30] is also correct), because the order of the elements in this column vector (roots) is irrelevant, since in multiplication the order in which you multiply is irrelevant (at least in scalar math). Therefore, any order, as long as all values are accounted for, is correct.
  3. “(s − 40)3(s − 80)” converts to “[40 ; 40 ; 40 ; 80]”. Each root has to be accounted for. Multiple roots must be accounted for each time they are multiplied.
  4. “(s3 − 11s2 + 38s − 40)(s − 3)” converts to “[2 ; 4 ; 5 ; 3]”. You must always remember to factor to a single power of s (even if this makes complex values). s3 − 11s2 + 38s − 40 factors into (s − 2)(s − 4)(s − 5).

Continuing, the easiest of the system representations to explain arises. State-variable has become popular in the professional industry, due largely to the ease of representing multi-input/multi-output systems. Several signals can be evaluated simultaneously in very sophisticated systems without having to trace through the transfer functions for each input to output. Several other subjects that may cross your path in your progression of control-theory knowledge (e.g. Kalman filter, sensitivity analysis), use this base structure to build upon. State-variable concepts are discussed in great detail starting in Section 2.21. For the present, let us consider the MATLAB representation of the following state and output equations, respectively:

Image

The “A” matrix represents the system dynamics, namely how the system is connected and where the integrators are located. “B” represents how inputs couple into the system. “C” represents how the outputs couple out of the system. “D” represents what portion of the inputs couples directly into the output. This representation may abstract the original design a little, but the advantages are quite significant. One such advantage is the improved precision of the representation, it suffers from fewer computer round-off-type problems.

Each of these three (transfer function, zero-pole-gain and state variable) representations have their advantages for visual inspection, but the conversion of them from one form to another can be cumbersome. MATLAB has realized this, and created several routines that allow you to convert from one representation to the next. A list of them, as well as their relations to each other, continuous and discrete versions, has been prepared and is stated under Model Conversions. A good exercise would be to pick a system, convert it to one of these representations, and then convert this representation to others with these routines. Practice in becoming familiar with these representations and converting between them is left to the readers’ discretion.

Another aspect to consider is whether your system is a continous-time or discrete-time system. In reality, modem systems (digitally controlled) read the continous input (analog data) at discrete intervals making hybrid (sampled-data) systems. Breaking these systems apart, we can separately look at the continuous parts and discrete parts, or we can create “equivalent” models of these systems by using conversion routines. The concepts of hybrid systems are mind-boggling, and it is often preferable to convert their representations to one or the other (continuous or discrete) “equivalent” system for analysis.

A utility to convert from continuous to discrete, called “C2D” comes with the “Signal and Systems” toolbox. (The professional Control System Toolbox has many utilities that go back and forth with a variety of methods for converting.) The MCSTD toolbox comes with the conceptual essentials (further elaborated in the demo m-file) to do almost all the conversions that the professional toolbox does. The MCSTD toolbox even gives and uses examples of these conversions, since they are mostly polynomial substitutions (see polysbst in the MCSTD toolbox). Once again, this is an excellent teaching tool for control-systems theory, while not giving you all of the professional Control System Toolbox features.

A visual implementation of the system modeling is also available. It utilizes the above data representations of the basic building blocks, and the capability to inter-connect the blocks. The Simulink Toolbox, used for system simulations, allows building of the system models in the visual sense. The Simulink developed model can be “queried” for the states contained in the system model.

H.  Summary of MATLAB and Modern Control System Theory and Design Toolbox Commands

An abbreviated list of the commonly predefined functions available from MATLAB, which are of prime interest to the control-system engineer, is listed in Table 2.2. By entering these commands, MATLAB processes them immediately and displays the results determined.

A list of the additional commands available from the Modern Control System Theory and Design Toolbox, to supplement the MATLAB commands, which are also of prime interest to the control-system engineer, is given in Table 2.3. By entering these commands, the data are processed immediately and the results are displayed. The control-system engineer will find these commands very useful in the analysis and design of control systems. For example, some practical control-system examples of the polynomial utilities are as follows (Bode plot and root locus are discussed starting in Chapter 6.):

•  Polysbst { go from s to jω domain,
{ transform (scale/transport/rotate) axis in root locus plot
{ continuous to discrete transformations (substitutions)
•  Polymag { Bode plot: pick any gain frequency (Odb = Phase margin (P.M.),
   3db = Band Width (B.W.)
•  Polyangl { Bode plot: pick any phase frequency (−180 = Gain Margin
   (G.M.)
•  Rootmag { Root locus: pick a particular s/z magnitude (Unit Circle)
•  Rootangl { Root locus: pick a particular damping angle
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.204