Solving non-linear and linear simultaneous equations with fsolve

버전 1.1.0.0 (1.46 KB) 작성자: Bruce Raine
solvesimul.m solves non-linear and linear simultaneous equations.
다운로드 수: 1.2K
업데이트 날짜: 2010/1/27

라이선스 보기

solvesimul.m can be easily adapted to solve more equations but as it stands it will solve 2 unknowns in 2 equations (1 non-linear and one linear).

To solve equations of this form...

a*x + b*y = A (1)
a1*x^2 + b1*y^2 = B (2)

...with fsolve (used by solvesimul.m) you need to rewrite them so that they equal zero.

so (1) and (2) become
a*x + b*y - A = 0 (1a)
a1*x^2 + b1*y^2 - B = 0 (2a)

then using a nested function approach (there are many other ways) you can solve some system of non-linear equations.
An example,

2*x + 3*y - 8 = 0
4*x^2 + 5*y^2 - 24 = 0

At the MATLAB command-line prompt you run the 'solvesimul' m-file function with the correct arguments
i.e. coefficients and constants in the equations in the appropriate order.
NB: please see final note below demo of the solvesimul command.

>> b=solvesimul(2,3,4,5,8,24);
1.0e-014 *

0
0.7105

>> b

b =

1.0000
2.0000

These are the solutions for the 2 equations i.e. x = 1, y=2.
----------------------------------------------------------------
The code I wrote for 'solvesimul' is attached. Save it to your working folder and run as above.
NB: you can use any one of the 3 fsolve formats by commenting out the other 2 you don't need in the attached m-file code.

Important:
You need to enter the args (i.e equation coefficients) to solvesimul.m in the order they appear in the equations with equation constants specified last in the correct order.

인용 양식

Bruce Raine (2024). Solving non-linear and linear simultaneous equations with fsolve (https://www.mathworks.com/matlabcentral/fileexchange/26259-solving-non-linear-and-linear-simultaneous-equations-with-fsolve), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2009b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

Updated title, summary and description fields.

1.0.0.0