Essential matlab for engineers and scientists

Page 369

Essential MATLAB for Engineers and Scientists

It just goes to show that you should never trust your intuition when it comes to statistics! Note that the Markov chain approach is not a simulation: one gets the theoretical probabilities each time (this can all be done mathematically, without a computer). But it is interesting to confirm the limiting probabilities by simulating the student’s progress, using a random number generator (see Exercise 15.5 at the end of Chapter 15).

16.3 Linear equations A problem that often arises in scientific applications is the solution of a system of linear equations, e.g. 3x + 2y − z

=

10

(16.2)

−x + 3y + 2z

=

5

(16.3)

x−y−z

=

−1.

(16.4)

MATLAB was designed to solve a system like this directly and very easily, as we shall now see. If we define the matrix A as ⎡

3 ⎣ A = −1 1

2 3 −1

⎤ −1 2 ⎦, −1

and the vectors x and b as ⎡

⎤ x x = ⎣ y ⎦, z

⎤ 10 b = ⎣ 5 ⎦, −1

we can write the above system of three equations in matrix form as ⎡

⎤⎡ ⎤ ⎡ ⎤ x 3 2 −1 10 ⎣ −1 3 2 ⎦⎣ y ⎦ = ⎣ 5 ⎦, 1 −1 −1 z −1 or even more concisely as the single matrix equation Ax = b.

348

(16.5)


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.