Ax = bTake this simple example:
A = randn(3, 3) b = randn(3, 1)
A = 0.52006 -0.79816 -0.71453 -0.020028 1.0187 1.3514 -0.034771 -0.13322 -0.22477 b = -0.58903 -0.29375 -0.84793Technically, you can solve it using the INV function.
x1 = inv(A)*b
x1 = -30.333 -56.674 42.054But as the documentation for inv suggests, there is a better way to solve this problem, both in terms of efficiency as well as accuracy. That is to use the backslash operator:
x2 = A\b
x2 = -30.333 -56.674 42.054Tim takes this one step further and extends the capability with his Factorize object. One of the benefits is that you can "reuse" this efficiency in different conditions:
c = randn(3, 1); F = factorize(A); x3 = F\b x4 = F\c;
x3 = -30.333 -56.674 42.054This is a simple 3-by-3 example for illustration, but you'll appreciate its power when you're working with larger systems. I like this entry for several reasons.
- He uses the new MATLAB Class system (introduced in R2008a). Specifically, he utilizes object-oriented techniques, such as property attributes and abstract classes.
- He includes a very thorough, pedagogical document that explains the uses of the object and the theory behind different techniques for solving linear systems.
- He includes a test suite for testing the accuracy, performance, error-handling, and display methods of the Factorize object.
コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。