Simultaneous Equation using reduced row method

1 Ansicht (letzte 30 Tage)
Harry Austin
Harry Austin am 2 Nov. 2020
Kommentiert: Image Analyst am 3 Nov. 2020
Hi, I am new to the software and am wondering how you would write a code which would solve any number of simultaneous equations. ie a code that when 3 equations were inputted would work out the answers as well as if you inputted 10 equations

Akzeptierte Antwort

Image Analyst
Image Analyst am 3 Nov. 2020
Put the coefficients into a matrix, then divide.
Syntax
Description
x = A\B solves the system of linear equations A*x = B. The matrices A and B must have the same number of rows. MATLAB® displays a warning message if A is badly scaled or nearly singular, but performs the calculation regardless.
  • If A is a scalar, then A\B is equivalent to A.\B.
  • If A is a square n-by-n matrix and B is a matrix with n rows, then x = A\B is a solution to the equation A*x = B, if it exists.
  • If A is a rectangular m-by-n matrix with m ~= n, and B is a matrix with m rows, then A\B returns a least-squares solution to the system of equations A*x= B.
Example:
% 2x + 4y + 3z = 3
% 3x + 5y + 2z = 8
% 1x + 2y + 5z = 9
A = [2,4,3; 3,5,2; 1,2,5]
B = [3;8;9]
xyz = A\B
% Other example from the help
A = magic(3)
B = [15; 15; 15];
x = A\B
If you still need help, give us your set of equations.
  6 Kommentare
Harry Austin
Harry Austin am 3 Nov. 2020
Thank you :)
Image Analyst
Image Analyst am 3 Nov. 2020
My pleasure. To thank people in the forum, you can award them "reputation points" by "Accepting" their answer and also clicking on the "Vote" icon. Thanks in advance.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by