See other catalogues for
The MathWorks
You may also be interested in
Text version of the page
| | | | | | | | | | | | | |
| | | |
| | | More About Matrices and Arrays | | |
| | | |
| | | Scalar Expansion Matrices and scalars can be combined in several different ways. For example, ascalarissubtracted from a matrix by subtracting it from each element. The average value of the elements in our magic square is 8.5, so B= A- 8.5 forms a matrix whose column sums are zero: B= | | |
| | | |
| | | | | | | | | | | | 7.5 | -5.5 | -6.5 | 4.5 | | | | -3.5 | 1.5 | 2.5 | -0.5 | | | | 0.5 | -2.5 | -1.5 | 3.5 | | | | -4.5 | 6.5 | 5.5 | -7.5 | | | | | | | | | | | |
| | | |
| | | sum(B) ans = 0000 With scalar expansion, MATLAB assigns a specified scalar to all indices in a range. For example, B(1:2,2:3) = 0 zeroes out a portion of B: B= | | |
| | | |
| | | | | | | | | | | | 7.5 | 0 | 0 | 4.5 | | | | -3.5 | 0 | 0 | -0.5 | | | | 0.5 | -2.5 | -1.5 | 3.5 | | | | -4.5 | 6.5 | 5.5 | -7.5 | | | | | | | | | | | |
| | | |
| | | Logical Subscripting The logical vectors created from logical and relational operations can be used to reference subarrays. Suppose X is an ordinary matrix and L is a matrix of the samesizethat is the result of some logical operation. Then X(L) specifies the elements of X where the elements of L are nonzero. | | |
| | | |
| | | 2-27 | | |
| | | |
| | | | | | | | | | | | | |