3.7. Matrix Manipulations

The shape and size of a matrix can be altered by using the following MATLAB commands:

3.7.1. Reshaping Matrices

Matrices can be reshaped into a vector or into any other appropriately sized matrix as described below:

3.7.1.1. Reshaping of a Matrix as a Vector

All the elements of a matrix A can be grouped into a single column vector b by the command b = A(:). Matrix A will be stored column wise in vector b i.e. first column is stored first, then second column and so on.

Example 3.7.

Let matrix . Reshape the matrix to a column vector.

Solution:

The command

A=[1 10 20; 2 5 6 ;7 8 9]

The following result is displayed: ...

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.