See other catalogues for
The MathWorks
You may also be interested in
Text version of the page
| | | | | | | | | | | | | | | | | | |
| | | |
| | | Creating and Concatenating Matrices | | |
| | | |
| | | This example constructs a 3 row, 5 column (or 3-by-5) matrix of numbers. Note that all rows must have the same number of elements: A = [12 62 93 -8 22; 16 2 87 43 91; -4 17 -72 95 6] A= 12 62 93 -8 22 16 2874391 -4 17 -72 95 6 The square brackets operator constructs two-dimensional matrices only, (including 0-by-0, 1-by-1, and 1-by-n matrices). To construct arrays of more than two dimensions, see "Creating Multidimensional Arrays" on page 1-58. For instructions on how to read or overwrite any matrix element, see "Matrix Indexing" on page 1-18. | | |
| | | |
| | | Entering Signed Numbers When entering signed numbers into a matrix, make sure that the sign immediately precedes the numeric value. Note that while the following two expressions are equivalent, | | |
| | | |
| | | 7-2+5 7-2+5 ans = ans = 10 10 | | |
| | | |
| | | the next two are not: | | |
| | | |
| | | [7-2+5] [7-2+5] ans = ans = 7-2 5 10 | | |
| | | |
| | | Specialized Matrix Functions MATLAB has a number of functions that create different kinds of matrices. Some create specialized matrices like the Hankel or Vandermonde matrix. The functions shown in the table below create matrices for more general use. | | |
| | | |
| | | | | | | | | | Function | Description | | | | ones | Create a matrix or array of all ones. | | | | | | | | | |
| | | |
| | | 1-5 | | |
| | | |
| | | | | | | | | | | | | | | | | | |