MLAB Beginner’s Guide by Daniel Kerner Revision Date: January 17, 2014 c Civilized Software, Inc. 12109 Heritage Park Circle Silver Spring, MD 20906 USA Tel: (301)962-3711 Email: [email protected] URL: http://www.civilized.com PREFACE MLAB Beginner’s Guide is an updated version of the book of the same name written by George A. Hutchinson and George Atta, and revised by Gary Knott and Bruce Krulwich, in the early 1980’s at the National Institutes of Health Division of Computer Research and Technology, Bethesda, MD. The original edition of this book provided an introduction to using the MLAB mathematical modeling program on a DEC PDP-10 mainframe computer. This book provides an introduction to using MLAB on Microsoft DOS/Windows (MSWindows), Apple Macintosh OS7/8/9/X, and Linux with X-Windows computers. Chapter and section names in the Table of Contents, figure numbers in the text and List of Figures, table numbers in the text and List of Tables, and page numbers in the index appear in the color blue and provide clickable links to the respective content. If the reader should find errors in this text, please send an email to [email protected] with a description of the error so that corrections can be made to future editions. Daniel Kerner Silver Spring, MD January, 2014 i Contents 1 A TUTORIAL MLAB SESSION 1 1.1 THE TUTORIAL .................................... 1 1.2 SUMMARY ........................................ 13 2 NUMERICAL CALCULATION IN MLAB 15 2.1 DATA TYPES ...................................... 15 2.2 SCALAR ASSIGNMENT STATEMENTS AND SCALAR EXPRESSIONS . 16 2.3 FUNCTIONS AND THE FUNCTION COMMAND ................. 23 2.4 RELATIONS AND DEFINITION OF FUNCTIONS BY CASES .......... 26 2.5 RECURSIVE FUNCTIONS AND THE TYPEOUT OPERATOR ......... 31 2.6 INDEXED SUMS, PRODUCTS, AND DEFINITE INTEGRALS .......... 33 2.7 EVALUATING AND FINDING ROOTS OF EXPRESSIONS ............ 36 2.8 DERIVATIVES OF FUNCTIONS ........................... 37 2.9 THE TYPE COMMAND ................................ 40 2.10 SUMMARY ........................................ 41 2.11 EXERCISES ....................................... 45 3 COMPUTATION WITH MATRICES IN MLAB 47 3.1 MATRIX ASSIGNMENT STATEMENTS AND MATRIX DIMENSIONS ..... 47 ii 3.2 ENTERING NUMBERS INTO A MATRIX ...................... 49 3.3 GENERATING ARITHMETIC SEQUENCE VECTORS .............. 54 3.4 MATRIX MANIPULATION OPERATIONS ..................... 58 3.5 MATRIX ARITHMETIC OPERATIONS ....................... 73 3.6 RANKORDER AND DISTRIBUTION OF VALUES IN A MATRIX ........ 81 3.7 TABULATION OF A FUNCTION ........................... 83 3.8 LINEAR INTERPOLATION .............................. 86 3.9 THE FOR COMMAND ................................. 88 3.10 SUMMARY ........................................ 91 3.11 EXERCISES ....................................... 93 4 MAKING PICTURES WITH MLAB 96 4.1 GRAPHICAL DISPLAY CONTROL COMMANDS ................. 96 4.2 WINDOW, CURVE, AND TITLE DATA OBJECTS ................. 97 4.3 THE DRAW COMMAND ................................ 105 4.4 THE AXIS COMMAND ................................. 126 4.5 THE TITLE COMMAND ................................ 128 4.6 TITLE MODIFICATION COMMANDS ........................ 134 4.7 EXAMINING AND MODIFYING CURVE AND WINDOW DATA ITEMS . 138 4.8 SIMPLIFYING MLAB GRAPHICS .......................... 142 4.9 SUMMARY ........................................ 147 4.10 EXERCISES ....................................... 148 5 INPUT AND OUTPUT FOR MLAB 154 5.1 FILES ........................................... 154 iii 5.2 THE SAVE AND USE COMMANDS ......................... 160 5.3 THE READ, READON, KREAD, AND KSREAD FUNCTIONS .......... 163 5.4 THE PRINT COMMAND ................................ 165 5.5 THE PLOTDEV AND PLOT COMMANDS ..................... 166 5.6 THE DO COMMAND .................................. 168 5.7 THE IF-THEN-ELSE COMMAND ........................... 171 5.8 THE MENUCHOICE, GETSTRINGS, and WREAD COMMANDS ........ 177 5.9 SUMMARY ........................................ 183 5.10 EXERCISES ....................................... 184 6 FURTHER MATRIX OPERATORS 189 6.1 MATRIX COMBINATION ............................... 189 6.2 MODIFYING DATA FOR ANALYSIS AND DISPLAY ............... 194 6.3 SHADING AREAS OF A POLYGON CURVE .................... 200 6.4 SURFACE CONTOURS ................................. 203 6.5 EIGENVALUES, EIGENVECTORS, AND COMPLEX NUMBERS ........ 208 6.6 SINGULAR VALUE DECOMPOSITION OF A MATRIX .............. 213 6.7 COVARIANCE AND CORRELATION ........................ 215 6.8 DISCRETE FOURIER TRANSFORMS ........................ 217 6.9 SUMMARY ........................................ 221 6.10 EXERCISES ....................................... 223 7 CURVE-FITTING IN MLAB 225 7.1 SUM-OF-SQUARED-ERROR CRITERION FOR CURVE-FITTING ....... 226 7.2 WEIGHTED-SUM-OF-SQUARED-ERROR CRITERION .............. 229 iv 7.3 EWT OPERATOR .................................... 233 7.4 FUNCTIONAL FORMS OF SEVERAL VARIABLES ................ 236 7.5 JOINT MODELS OF SEVERAL FUNCTIONAL FORMS ............. 236 7.6 THE CONSTRAINTS COMMAND .......................... 238 7.7 GENERAL PROBLEM OF CURVE-FITTING A FUNCTIONAL FORM . 241 7.8 PREPARING DATA FOR CURVE-FITTING OPERATIONS ............ 241 7.9 THE FIT COMMAND .................................. 244 7.10 THE FIT COMMAND CONTROL VARIABLES ................... 251 7.11 FORMULATING FUNCTIONAL FORM MODELS ................. 253 7.12 LINEAR MODELS .................................... 257 7.13 STATISTICAL CONSIDERATIONS FOR CURVE-FITTING ............ 259 7.14 CURVE-FITTING SEARCH STRATEGIES ...................... 260 7.15 INITIAL PARAMETER ESTIMATES FOR NONLINEAR MODELS ....... 271 7.16 SUMMARY ........................................ 273 7.17 EXERCISES ....................................... 275 8 SYSTEMS OF DIFFERENTIAL EQUATIONS IN MLAB 280 8.1 A FIRST ORDER DIFFERENTIAL EQUATION SOLVED IN MLAB ....... 280 8.2 COUPLED FIRST-ORDER DIFFERENTIAL EQUATIONS SOLVED IN MLAB 283 8.3 HIGHER ORDER DIFFERENTIAL EQUATION SOLVING IN MLAB . 290 8.4 CONTROLLING THE DIFFERENTIAL EQUATION SOLVER .......... 293 8.5 AN EXAMPLE OF CURVE-FITTING A DIFFERENTIAL EQUATION . 298 8.6 AN EXAMPLE OF A BOUNDARY VALUE DIFFERENTIAL EQUATION . 300 8.7 THE FIT COMMAND FOR DIFFERENTIAL EQUATIONS ............ 301 8.8 SUMMARY ........................................ 302 8.9 EXERCISES ....................................... 307 v A FONT TABLES 314 B LIST OF TABLES 326 C LIST OF FIGURES 331 D BIBLIOGRAPHY 335 E INDEX 336 vi Chapter 1 A TUTORIAL MLAB SESSION In this first chapter, we will go through a simple MLAB session from beginning to end. In order to show many different aspects of MLAB, only brief explanations of commands are given. MLAB can run on many different types of computers. Initially, of course, you must carry out the appropriate steps needed to install MLAB on your computer. These steps are detailed in the installation instructions provided with the MLAB distribution. 1.1 THE TUTORIAL If the operating system on your computer has a graphical user interface (i.e. MSWindows or Macintosh), double click on the MLAB icon on the Desktop to begin the MLAB session. If the operating system on your computer has a command line interface (Linux/Unix or DOS), type the command mlab in response to the operating system prompt in a bash-shell or DOS command window to begin the MLAB session. A response similar to the following should appear on the display screen or in a new window: MLAB: Mathematical Modeling System, Revision: November 5, 2013 Executing file: /usr/local/lib/mlab/mlab Copyright: Civilized Software, Inc. (301)962-3711, email:[email protected] Web-site: WWW.CIVILIZED.COM Tue Nov 5 11:00:03 2013 Your current working directory: is C:\Users\csi\mlab\ Use FILEDIR to reach any other directory. ’* ’ is the command prompt This copy of MLAB belongs to csi 1 Type ’exit’ to exit from MLAB, or type another MLAB command. * In this Beginner’s Guide, text that the user types at the keyboard and text that the computer produces itself are typed in BOLD TYPEWRITER FONT. MLAB will then display a menu with the three options: Look at a list of MLAB demonstration do-files. • Go to top-level MLAB. • Display some tips on using MLAB. • (This is done by executing the do-file STARTUP.DO.) Selecting the first option causes MLAB to execute the do-file MLABEX.DO in the EXAMPLES sub-directory; MLABEX.DO displays a menu of example scripts, many of which are explained in separate chapters of the MLAB Application Manual. Selecting an example script from the menu will execute the script, and then recursively executes the MLABEX.DO script. While executing an example script, MLAB may pause occasionally to display instructions or a graph; strike any key on the keyboard to continue. Selecting the second option causes MLAB to terminate the STARTUP.DO script file and wait for a command. Selecting the third option causes MLAB to print a list of suggestions on how to proceed with MLAB. Striking the RETURN/ENTER key or clicking the CONTINUE button causes MLAB to execute the do-file MLABEX.DO, which was described previously. [Note, if you edit the file STARTUP.DAT in the directory where the MLAB application resides, type a number–i.e. ”1”–in the file, and save the file, then when the script STARTUP.DO is executed in future MLAB sessions, MLAB will simply go to top-level.] For the purpose of this tutorial, select the second option–Go to top-level MLAB. That will print an asterisk on the last line of the MLAB command window. This asterisk (*) is MLAB’s prompt for the user
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages353 Page
-
File Size-