O'Reilly logo

Learning to Program with MATLAB: Building GUI Tools by Craig S. Lent

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

images

4.1    Entering and manipulating matrices

4.2    Operations on matrices

4.3    Solving linear systems: The backslash operator

4.4    Special matrix functions

The name MATLAB is derived from “Matrix Laboratory,” so it’s no surprise that this programming language is particularly strong at handling matrices. Matrices and vectors have many applications in science and engineering. Mathematically a matrix is simply a two-dimensional array of numbers. Given a matrix A, one specifies a particular element with two integer indices. For example, the element in the 2nd row and 3rd column is written A2,3. In MATLAB, this would be denoted A(2,3).

Many of the techniques for manipulating matrices are straightforward extensions of those for manipulating vectors described in Chapter 2. Array indexing and element-by-element mathematical operations behave just as in the case of vectors. Several operations on matrices are new, however: the matrix-vector product, matrix-matrix multiplication, the inverse of a matrix, and the determinant of a matrix.

A very common use for matrix operations is to characterize a system of linear equations that you want to solve simultaneously. Section 4.3 describes how to use matrix operations to solve such a linear system, and includes as and extended example an electric circuit problem.

After mastering the material in this chapter you should be able to write programs ...

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