Programming Previous page   Next Page

Diminishing the Size of a Matrix

You can delete rows and columns from a matrix by assigning the empty array [] to those rows or columns. Start with

Then, delete the second column of A using

This changes matrix A to

If you delete a single element from a matrix, the result isn't a matrix anymore. So expressions like

result in an error. However, you can use linear indexing to delete a single element, or a sequence of elements. This reshapes the remaining elements into a row vector:

results in

Previous page  Resizing and Reshaping Matrices Reshaping a Matrix Next page

© 1994-2005 The MathWorks, Inc.