Simultaneous Equation using reduced row method

조회 수: 2 (최근 30일)
Harry Austin
Harry Austin 2020년 11월 2일
댓글: Image Analyst 2020년 11월 3일
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

채택된 답변

Image Analyst
Image Analyst 2020년 11월 3일
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
Harry Austin
Harry Austin 2020년 11월 3일
Thank you :)
Image Analyst
Image Analyst 2020년 11월 3일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by