Using Matlab V 6

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Year: 2000

Language: English
Pages: 874

Development Environment......Page 25
Starting and Quitting MATLAB......Page 27
Startup Directory for MATLAB......Page 29
Startup Options......Page 30
Reducing Startup Time with Toolbox Path Caching......Page 35
Running a Script When Quitting MATLAB......Page 40
Using the Desktop......Page 41
Desktop Tools......Page 44
Launch Pad......Page 45
Opening and Closing Desktop Tools......Page 47
Resizing Windows......Page 49
Moving Windows......Page 50
Using Predefined Desktop Configurations......Page 56
Context Menus......Page 57
Keyboard Shortcuts and Accelerators......Page 58
Using the Clipboard......Page 59
Accessing The MathWorks on the Web......Page 60
Setting Preferences......Page 61
General Preferences for MATLAB......Page 63
Running MATLAB Functions......Page 65
Running Functions and Entering Variables......Page 66
Controlling Input and Output......Page 68
Running Programs......Page 75
Preferences for the Command Window......Page 76
Viewing Functions in the Command History Window......Page 79
Running Functions from the Command History Window......Page 80
Copying Functions from the Command History Window......Page 81
Getting Help......Page 83
Types of Information......Page 85
Using the Help Browser......Page 86
Changing the Size of the Help Browser......Page 87
Using the Product Filter......Page 88
Viewing the Contents Listing in the Help Browser......Page 89
Finding Documentation Using the Index......Page 91
Searching Documentation......Page 93
Bookmarking Favorite Pages......Page 95
Viewing Documentation in the Display Pane......Page 96
Bookmarking Pages......Page 97
Evaluating a Selection......Page 98
Viewing Web Pages......Page 99
Preferences for the Help Browser......Page 100
Product Filter – Constraining the Product Documentation......Page 101
Help Fonts Preferences – Specifying Font Name, Style, and Size......Page 102
Printing the PDF Version of Documentation......Page 105
Using Help Functions......Page 107
Getting Help in the Command Window – the help Function......Page 108
Running Demos......Page 110
Getting Version and License Information......Page 111
Participating in the Newsgroup for MathWorks Products......Page 112
Workspace, Path, and File Operations......Page 113
Workspace Browser......Page 115
Viewing and Editing Workspace Variables Using the Array Editor......Page 122
How the Search Path Works......Page 126
Viewing and Setting the Search Path......Page 127
Current Directory Browser......Page 132
Viewing and Making Changes to Directories......Page 134
Creating, Renaming, Copying, and Removing Directories and Files......Page 135
Opening, Running, and Viewing the Content of Files......Page 138
Finding and Replacing Content Within Files......Page 140
Preferences for the Current Directory Browser......Page 142
Importing and Exporting Data......Page 145
Using the Import Wizard with Text Data......Page 148
Using Import Functions with Text Data......Page 153
Importing Numeric Text Data......Page 155
Importing Delimited ASCII Data Files......Page 156
Importing Numeric Data with Text Headers......Page 157
Importing Mixed Alphabetic and Numeric Data......Page 158
Exporting ASCII Data......Page 160
Exporting Delimited ASCII Data Files......Page 161
Using the diary Command to Export Data......Page 162
Using the Import Wizard with Binary Data Files......Page 164
Using Import Functions with Binary Data......Page 166
Exporting Binary Data......Page 169
Exporting MATLAB Graphs in AVI Format......Page 171
Working with HDF Data......Page 173
Overview of MATLAB HDF Support......Page 174
MATLAB HDF Function Calling Conventions......Page 175
Importing HDF Data into the MATLAB Workspace......Page 177
Exporting MATLAB Data in an HDF File......Page 185
Including Metadata in an HDF File......Page 191
Using the MATLAB HDF Utility API......Page 193
Using Low-Level File I/O Functions......Page 195
Opening Files......Page 196
Reading Binary Data......Page 198
Writing Binary Data......Page 199
Controlling Position in a File......Page 200
Reading Strings Line-By-Line from Text Files......Page 202
Reading Formatted ASCII Data......Page 203
Writing Formatted Text Files......Page 205
Closing a File......Page 206
Editing and Debugging M-Files......Page 207
Starting the Editor/Debugger......Page 209
Opening Existing M-Files in the Editor/Debugger......Page 210
Opening the Editor Without Starting MATLAB......Page 211
Closing the Editor/Debugger......Page 212
Appearance of an M-File......Page 213
Navigating in an M-File......Page 215
Closing M-Files......Page 219
Finding Errors......Page 221
Debugging Example – The Collatz Problem......Page 222
Trial Run for Example......Page 224
Using Debugging Features......Page 226
Preferences for the Editor/Debugger......Page 238
General Preferences for the Editor/Debugger......Page 239
Font & Colors Preferences for the Editor/Debugger......Page 240
Display Preferences for the Editor/Debugger......Page 241
Keyboard and Indenting Preferences for the Editor/ Debugger......Page 243
Printing Preferences for the Editor/Debugger......Page 245
Improving M-File Performance – the Profiler......Page 247
What Is Profiling?......Page 249
The profile Function......Page 250
An Example Using the Profiler......Page 252
Viewing Profile Reports......Page 253
Profile Plot......Page 258
Saving Profile Reports......Page 259
Interfacing with Source Control Systems......Page 263
Process of Interfacing to an SCS......Page 265
Function Alternative for Viewing the SCS......Page 267
For ClearCase on UNIX Only – Set a View and Check Out a Directory......Page 268
Specifying the Project Configuration File – For PVCS Only......Page 269
Checking Files into the Source Control System......Page 270
Function Alternative for Checking In Files......Page 271
Checking Files Out of the SCS......Page 272
Undoing the Check-Out......Page 273
Using Notebook......Page 275
Creating an M-Book......Page 277
Protecting the Integrity of Your Workspace......Page 280
Ensuring Data Consistency......Page 281
Defining Cell Groups......Page 282
Defining Calc Zones......Page 284
Converting an Input Cell to Text......Page 285
Evaluating MATLAB Commands......Page 286
Evaluating Cell Groups......Page 287
Evaluating a Calc Zone......Page 288
Using a Loop to Evaluate Input Cells Repeatedly......Page 289
Converting Output Cells to Text......Page 290
Deleting Output Cells......Page 291
Modifying Styles in the M-Book Template......Page 292
Choosing Loose or Compact Format......Page 293
Controlling Graphic Output......Page 294
Configuring Notebook......Page 298
Define Autoinit Cell Command......Page 300
Define Input Cell Command......Page 301
Evaluate Cell Command......Page 302
Evaluate Loop Command......Page 303
Group Cells Command......Page 304
Toggle Graph Output for Cell Command......Page 305
Ungroup Cells Command......Page 306
Mathematics......Page 309
Matrices and Linear Algebra......Page 311
Function Summary......Page 313
Creation......Page 315
Vector Products and Transpose......Page 317
Matrix Multiplication......Page 319
The Kronecker Tensor Product......Page 321
Vector and Matrix Norms......Page 322
Overview......Page 323
Overdetermined Systems......Page 325
Underdetermined Systems......Page 328
Overview......Page 331
Pseudoinverses......Page 332
Cholesky Factorization......Page 335
LU Factorization......Page 336
QR Factorization......Page 338
Matrix Powers and Exponentials......Page 342
Eigenvalues......Page 345
Singular Value Decomposition......Page 349
Polynomials and Interpolation......Page 351
Polynomial Function Summary......Page 353
Polynomial Roots......Page 354
Polynomial Evaluation......Page 355
Polynomial Derivatives......Page 356
Polynomial Curve Fitting......Page 357
Partial Fraction Expansion......Page 358
Interpolation Function Summary......Page 360
One-Dimensional Interpolation......Page 361
Two-Dimensional Interpolation......Page 363
Comparing Interpolation Methods......Page 364
Interpolation and Multidimensional Arrays......Page 366
Triangulation and Interpolation of Scattered Data......Page 369
Tessellation and Interpolation of Scattered Data in Higher Dimensions......Page 376
Selected Bibliography......Page 385
Data Analysis and Statistics......Page 387
Column-Oriented Data Sets......Page 390
Function Summary......Page 394
Covariance and Correlation Coefficients......Page 397
Finite Differences......Page 398
Missing Values......Page 400
Removing Outliers......Page 401
Regression and Curve Fitting......Page 403
Polynomial Regression......Page 404
Linear-in-the-Parameters Regression......Page 405
Multiple Regression......Page 407
Polynomial Fit......Page 408
Analyzing Residuals......Page 410
Exponential Fit......Page 413
Error Bounds......Page 416
The Basic Fitting Interface......Page 417
Difference Equations and Filtering......Page 426
Function Summary......Page 428
Introduction......Page 429
Magnitude and Phase of Transformed Data......Page 434
FFT Length Versus Speed......Page 435
Function Functions......Page 437
Function Summary......Page 439
Representing Functions in MATLAB......Page 440
Plotting Mathematical Functions......Page 442
Minimizing Functions of One Variable......Page 445
Setting Minimization Options......Page 446
Finding Zeros of Functions......Page 448
Troubleshooting......Page 450
Converting Your Optimization Code to MATLAB Version 5 Syntax......Page 451
Example: Computing the Length of a Curve......Page 454
Example: Double Integration......Page 455
Differential Equations......Page 457
ODE Function Summary......Page 459
Introduction to Initial Value ODE Problems......Page 461
Initial Value Problem Solvers......Page 462
Representing ODE Problems......Page 466
Improving ODE Solver Performance......Page 471
Examples: Applying the ODE Initial Value Problem Solvers......Page 486
Questions and Answers, and Troubleshooting......Page 505
BVP Function Summary......Page 512
Introduction to Boundary Value ODE Problems......Page 513
Boundary Value Problem Solver......Page 515
Representing BVP Problems......Page 518
Making a Good Initial Guess......Page 522
Improving BVP Solver Performance......Page 526
PDE Function Summary......Page 532
Introduction to PDE Problems......Page 533
MATLAB Partial Differential Equation Solver......Page 534
Representing PDE Problems......Page 538
Improving PDE Solver Performance......Page 543
Example: Electrodynamics Problem......Page 544
Selected Bibliography......Page 549
Sparse Matrices......Page 551
Function Summary......Page 553
Sparse Matrix Storage......Page 556
Creating Sparse Matrices......Page 557
Importing Sparse Matrices from Outside MATLAB......Page 562
Information About Nonzero Elements......Page 563
Viewing Sparse Matrices Graphically......Page 565
The find Function and Sparse Matrices......Page 566
Introduction to Adjacency Matrices......Page 567
The Bucky Ball......Page 568
An Airflow Model......Page 573
Standard Mathematical Operations......Page 575
Permutation and Reordering......Page 576
Factorization......Page 580
Simultaneous Linear Equations......Page 586
Eigenvalues and Singular Values......Page 589
Selected Bibliography......Page 592
Programming and Data Types......Page 593
M-File Programming......Page 595
Kinds of M-Files......Page 597
Providing Help for Your Programs......Page 598
Creating M-Files: Accessing Text Editors......Page 599
Simple Script Example......Page 601
Simple Function Example......Page 602
Basic Parts of a Function M-File......Page 603
Function Names......Page 605
How Functions Work......Page 606
Checking the Number of Function Arguments......Page 608
Passing Variable Numbers of Arguments......Page 610
Local and Global Variables......Page 613
Persistent Variables......Page 614
Special Values......Page 615
Data Types......Page 616
Arithmetic Operators......Page 619
Relational Operators......Page 621
Logical Operators......Page 622
Operator Precedence......Page 625
if, else, and elseif......Page 628
switch......Page 630
while......Page 632
for......Page 633
break......Page 634
return......Page 635
Subfunctions......Page 636
Private Functions......Page 638
Subscripts......Page 639
Advanced Indexing......Page 642
feval......Page 645
Command/Function Duality......Page 647
Operating on an Empty Matrix......Page 648
Using Empty Matrices with If or While......Page 649
Error Handling with eval and lasterr......Page 650
Displaying Error and Warning Messages......Page 651
Date Formats......Page 653
Current Date and Time......Page 658
Pausing During Execution......Page 660
Shell Escape Functions......Page 661
Vectorizing Loops......Page 662
Preallocating Arrays......Page 664
Making Efficient Use of Memory......Page 665
Character Arrays (Strings)......Page 671
Creating Character Arrays......Page 675
Creating Two-Dimensional Character Arrays......Page 676
Converting Characters to Numeric Values......Page 677
Converting to a Cell Array of Strings......Page 678
Comparing Strings For Equality......Page 680
Comparing for Equality Using Operators......Page 681
Categorizing Characters Within a String......Page 682
Searching and Replacing......Page 683
String/Numeric Conversion......Page 685
Array/String Conversion......Page 686
Multidimensional Arrays......Page 687
Multidimensional Arrays......Page 689
Creating Multidimensional Arrays......Page 690
Accessing Multidimensional Array Properties......Page 694
Indexing......Page 695
Reshaping......Page 696
Permuting Array Dimensions......Page 698
Operating Element-by-Element......Page 700
Operating on Planes and Matrices......Page 701
Organizing Data in Multidimensional Arrays......Page 702
Multidimensional Cell Arrays......Page 704
Multidimensional Structure Arrays......Page 705
Applying Functions to Multidimensional Structure Arrays......Page 706
Structures and Cell Arrays......Page 707
Structures......Page 709
Building Structure Arrays......Page 710
Accessing Data in Structure Arrays......Page 712
Applying Functions and Operators......Page 715
Writing Functions to Operate on Structures......Page 716
Organizing Data in Structure Arrays......Page 717
Nesting Structures......Page 722
Cell Arrays......Page 724
Creating Cell Arrays......Page 725
Obtaining Data from Cell Arrays......Page 728
Deleting Cells......Page 729
Replacing Lists of Variables with Cell Arrays......Page 730
Organizing Data in Cell Arrays......Page 732
Nesting Cell Arrays......Page 734
Converting Between Cell and Numeric Arrays......Page 735
Cell Arrays of Structures......Page 736
Function Handles......Page 739
Benefits of Using Function Handles......Page 741
A Simple Function Handle......Page 743
Maximum Length of a Function Name......Page 745
Function Evaluation and Overloading......Page 747
Examples of Function Handle Evaluation......Page 748
Displaying Function Handle Information......Page 751
Converting Function Handles to Function Names......Page 752
Converting Function Names to Function Handles......Page 753
Testing for Equality......Page 754
Saving and Loading Function Handles......Page 756
Including Path In the Function Handle Constructor......Page 757
Evaluating a Nonscalar Function Handle......Page 758
Historical Note - Evaluating Function Names......Page 759
MATLAB Classes and Objects......Page 761
Features of Object-Oriented Programming......Page 763
Creating Objects......Page 764
Invoking Methods on Objects......Page 765
Debugging Class Methods......Page 766
Setting Up Class Directories......Page 767
Tips for C++ and Java Programmers......Page 768
The MATLAB Canonical Class......Page 769
The Class Constructor Method......Page 770
Identifying Objects Outside the Class Directory......Page 771
The display Method......Page 772
The set and get Methods......Page 773
Indexed Reference Using subsref and subsasgn......Page 774
How to Write subsref......Page 776
Defining end Indexing for an Object......Page 777
Indexing an Object with Another Object......Page 778
Converter Methods......Page 779
Overloading Operators......Page 780
Overloading Functions......Page 782
The Polynom Constructor Method......Page 783
Converter Methods for the Polynom Class......Page 784
The Polynom subsref Method......Page 787
Overloading Arithmetic Operators for polynom......Page 788
Overloading Functions for the Polynom Class......Page 790
Listing Class Methods......Page 792
Simple Inheritance......Page 794
Multiple Inheritance......Page 795
Aggregation......Page 796
Inheritance Model for the Asset Class......Page 797
The Asset Constructor Method......Page 798
The Asset set Method......Page 800
The Asset subsref Method......Page 801
The Asset subsasgn Method......Page 802
The Asset display Method......Page 803
Designing the Stock Class......Page 804
The Stock Constructor Method......Page 805
The Stock set Method......Page 807
The Stock subsref Method......Page 808
The Stock subsasgn Method......Page 810
The Stock display Method......Page 811
Designing the Portfolio Class......Page 813
The Portfolio Constructor Method......Page 814
The Portfolio display Method......Page 815
The Portfolio pie3 Method......Page 816
Creating a Portfolio......Page 817
Modifying Objects During Save or Load......Page 819
Summary of Code Changes......Page 820
The loadobj Method......Page 821
Changing the Portfolio Constructor......Page 822
The Portfolio subsref Method......Page 823
Object Precedence......Page 824
Specifying Precedence of User-Defined Classes......Page 825
Selecting a Method......Page 826
Querying Which Method MATLAB Will Call......Page 829
External Interfaces and the MATLAB API......Page 831
Finding the Documentation in Online Help......Page 832
Reference Documentation......Page 834
Index......Page 837