O'Reilly logo

MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] by Manoj Kumar Sharma, Ashok Kumar Goel, Raj Kumar Bansal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.6. Multi-Dimensional Matrices and Arrays

Matrix dimensions are defined automatically. However, if it is desired to know the size of an existing matrix A, command, size(A), can be used. The format is as follows:

size(A)

The command returns the number of elements of the matrix in each dimension. These numbers returned by the size command can be assigned to variables and stored for use later in the program. For example, if the matrix is two-dimensional, the following command can be used:

[m, n] = size(A)

When executed, it will assign the number of rows of matrix A to variable ‘m’ and number of columns to variable ‘n’.

Referring to the matrix A in Section 3.5.1, the size can be obtained by the following command:

[m, n] = size(A)

This gives ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required