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 계정에 로그인하거나 계정을 새로 만드십시오.