MATLAB Programming
MATLAB Programming MATLAB Programming
Contents 1 Data Structures Creating and Concatenating Matrices ............... 1-3 Constructing a Simple Matrix ....................... 1-3 Specialized Matrix Functions ........................ 1-5 Concatenating Matrices ............................ 1-7 Matrix Concatenation Functions ..................... 1-8 Generating a Numeric Sequence ..................... 1-10 Combining Unlike Data Types ....................... 1-12 Matrix Indexing ................................... 1-18 Accessing Single Elements .......................... 1-18 Linear Indexing ................................... 1-19 Functions That Control Indexing Style ................ 1-19 Accessing Multiple Elements ........................ 1-20 Logical Indexing .................................. 1-23 Indexing on Assignment ............................ 1-23 Getting Information About a Matrix ................. 1-24 Dimensions of the Matrix ........................... 1-24 Data Types Used in the Matrix ...................... 1-25 Data Structures Used in the Matrix .................. 1-26 Resizing and Reshaping Matrices ................... 1-27 Expanding the Size of a Matrix ...................... 1-27 Diminishing the Size of a Matrix ..................... 1-31 Reshaping a Matrix ................................ 1-32 Preallocating Memory .............................. 1-34 Shifting and Sorting Matrices ...................... 1-37 Shift and Sort Functions ............................ 1-37 Shifting the Location of Matrix Elements .............. 1-37 Sorting the Data in Each Column .................... 1-39 Sorting the Data in Each Row ....................... 1-39 Sorting Row Vectors ............................... 1-40 v
- Page 1 and 2: MATLAB ® 7 Programming
- Page 3: Revision History June 2004 First pr
- Page 7 and 8: Identifying Numeric Types .........
- Page 9 and 10: Logical Operators .................
- Page 11 and 12: M-File Scripts ....................
- Page 13 and 14: Supported File Formats ............
- Page 15 and 16: Using the MATLAB HDF4 High-Level Fu
- Page 17 and 18: Building on Other Classes .........
- Page 19 and 20: Testing the Validity of a Timer Obj
- Page 21 and 22: Passing Arguments in a Cell Array .
- Page 23 and 24: Determining Filenames at Run-Time .
- Page 25 and 26: 1 Data Structures The most basic da
- Page 27 and 28: Creating and Concatenating Matrices
- Page 29 and 30: Creating and Concatenating Matrices
- Page 31 and 32: Creating and Concatenating Matrices
- Page 33 and 34: Creating and Concatenating Matrices
- Page 35 and 36: Creating and Concatenating Matrices
- Page 37 and 38: Creating and Concatenating Matrices
- Page 39 and 40: Creating and Concatenating Matrices
- Page 41 and 42: 1 Data Structures 1-17
- Page 43 and 44: Matrix Indexing Linear Indexing Wit
- Page 45 and 46: Matrix Indexing B = A; B(1:3:16) =
- Page 47 and 48: Matrix Indexing 3 3 3 3 3 3 3 3 3 3
- Page 49 and 50: Getting Information About a Matrix
- Page 51 and 52: Resizing and Reshaping Matrices Res
- Page 53 and 54: Resizing and Reshaping Matrices Add
Contents<br />
1<br />
Data Structures<br />
Creating and Concatenating Matrices ............... 1-3<br />
Constructing a Simple Matrix ....................... 1-3<br />
Specialized Matrix Functions ........................ 1-5<br />
Concatenating Matrices ............................ 1-7<br />
Matrix Concatenation Functions ..................... 1-8<br />
Generating a Numeric Sequence ..................... 1-10<br />
Combining Unlike Data Types ....................... 1-12<br />
Matrix Indexing ................................... 1-18<br />
Accessing Single Elements .......................... 1-18<br />
Linear Indexing ................................... 1-19<br />
Functions That Control Indexing Style ................ 1-19<br />
Accessing Multiple Elements ........................ 1-20<br />
Logical Indexing .................................. 1-23<br />
Indexing on Assignment ............................ 1-23<br />
Getting Information About a Matrix ................. 1-24<br />
Dimensions of the Matrix ........................... 1-24<br />
Data Types Used in the Matrix ...................... 1-25<br />
Data Structures Used in the Matrix .................. 1-26<br />
Resizing and Reshaping Matrices ................... 1-27<br />
Expanding the Size of a Matrix ...................... 1-27<br />
Diminishing the Size of a Matrix ..................... 1-31<br />
Reshaping a Matrix ................................ 1-32<br />
Preallocating Memory .............................. 1-34<br />
Shifting and Sorting Matrices ...................... 1-37<br />
Shift and Sort Functions ............................ 1-37<br />
Shifting the Location of Matrix Elements .............. 1-37<br />
Sorting the Data in Each Column .................... 1-39<br />
Sorting the Data in Each Row ....................... 1-39<br />
Sorting Row Vectors ............................... 1-40<br />
v