Getting Started Previous page   Next Page

Scalar Expansion

Matrices and scalars can be combined in several different ways. For example, a scalar is subtracted from a matrix by subtracting it from each element. The average value of the elements in our magic square is 8.5, so

forms a matrix whose column sums are zero:

With scalar expansion, MATLAB assigns a specified scalar to all indices in a range. For example,

zeroes out a portion of B:


Previous page  Multivariate Data Logical Subscripting Next page

© 1994-2005 The MathWorks, Inc.