MATLAB Guide

Chapter 5: Matrices

An m-by- n matrix is a two-dimensional array of numbers consisting of m rows and n columns. Special cases are a column vector ( n = 1) and a row vector ( m = 1).

Matrices are fundamental to MATLAB, and even if you are not intending to use MATLAB for linear algebra computations you need to become familiar with matrix generation and manipulation. In versions 3 and earlier of MATLAB there was only one data type: the complex matrix. [2] Nowadays MATLAB has several data types (see Chapter 18) and matrices are special cases of a double: a double precision multidimensional array.

5.1 Matrix Generation

Matrices can be generated in several ways. Many elementary matrices can be constructed directly with a MATLAB function; see Table 5.1. The matrix of zeros, the matrix of ones and the identity matrix (which has ones on the diagonal and zeros elsewhere) are returned by the functions zeros, ones and eye, respectively. All have the same syntax. For example, zeros(m,n) or zeros([m,n]) produces an m-by- n matrix of zeros, while zeros (n) produces an n-by-n matrix. Examples:

   <span class="unicode">?</span> zeros(2)   ans =        0    0        0    0   <span class="unicode">?</span> ones(2,3)   ans =        1 ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Analog-to-Digital Converter (ADC) Chips
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.