简体   繁体   中英

Simple way to solve a system of linear equations in Matlab?

I'm looking for an easy and fast solution to the following problem: I have three 3D vectors x_i , three 3D vectors y_i , a 3D vector b and a 3x3 matrix A with coefficients a11 - a33 (that are unknown).

The relation is as follows:

x_i = A * y_i + b

That resolves to

x_i_1 = ( a11 * y_1_1 + a12 * y_2_1 + a13 * y_3_1 ) + b_1

etc.

So there are 9 equations and 9 unknown variables a11 - a33, easy peasy math. But how do I solve this system using build in Matlab functions?

If you know the 9 equations and 9 unknowns, then just pretend like the 9 unknowns live in a column vector called r , and write the rows of a 9x9 matrix called C to store the coefficients. If the left-hand side of the 9 equations is also stored in a column vector x then you'll be solving something like

Cr = x

And this is simply done in Matlab with

r = C\x;

Now r stores the solution for the 9 unknowns (assuming that solutions exist, etc.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM