working on matrices 3x3 in Matlab (2)
September 14, 2009
So after a few days of working on the matrices and its mathematical operations, theories and conceptional components (especially with matlab), I found a useful way to quickly determine whether a system is, either unique solution, no solution, or infinite solution.
First of all, I think I have thought too much about matrices and constructing a program. The objective, after spending a few days indeed, is probably just to find out "what number will produce" each of the three conditions. However, number goes on forever. But if we set a range for alpha and beta (the two variables we use) in the program, then there is a purpose for the program.
Matlab, just like any other programming language, has its own library, a collection of operations and pre-defined source-codes to use through the MatLab. For matrices, we do not need to worry about the operations. I probably had thought too much about "writing a program". I can still develop one, it isn't that hard once you know matrices' operations.
I can also make the program without doing the loop, simply just a program with the following sets of statements, and return a message to tell which condition is produce.
Now, the tools to determine each conditions quickly is to use the rule of "rank".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | >> alpha = 3, beta = 4, A=[(alpha) 2 0;0 1 2; 0 0 0], b=[(beta);0;1], rref(A), X=A\b, rref([A b]), rank(A), rank([A b]) alpha = 3 beta = 4 A = 3 2 0 0 1 2 0 0 0 b = 4 0 1 ans = 1.0000 0 -1.3333 0 1.0000 2.0000 0 0 0 Warning: Matrix is singular to working precision. X = NaN -Inf Inf ans = 1.0000 0 -1.3333 0 0 1.0000 2.0000 0 0 0 0 1.0000 ans = 2 ans = 3 |
if rank(A) = rank([A b]) = u.s and infinite solution may exit
else
no solution exitif rank(A) = # of unknowns, u.s exit
else
infinite solution exit.
If these statements are valid and true, then the first half of the program is just to create a loop and set a range to alpha and beta. The computer will print out the pair of alpha and beta when (1) there is no solution and (2) infinite solution. For unique solution, there is no need to print out the alpha and beta. Clear enough?