Solving non-linear (and linear) simultaneous equations with 'solve' - version 2
symsolvesimulv2.m can be easily adapted to solve more equations but as it stands it will solve 2 unknowns in 2 non-linear equations (can be linear too or a mixture).
Big change: It now has data input integrity checking.
At the MATLAB command-line prompt you run the 'symsolvesimulv2' m-file function with the correct vector arguments i.e. exponents, coefficients and constants in the equations in the appropriate order.
>> help symsolvesimulv2
solves a system (a pair) of non-linear or linear equations or a mixture,
returning a n x 2 column solution vector for x and y. The first parameter
is a row vector (1 x 4) of exponents used in both equations. An exponent
of one for both terms indicates a linear equation. The second parameter
(1 x 6) is also a row vector of all the coefficients and the constants
used in both equations. The order of both vector's elements is critical.
Note that there may be more than 1 solution for x and y (sometimes
complex)
and that they are presented in a symbolic format at times rather than a
pure numeric format.
USAGE: symsolvesimulv2([ex1 ex2 ex3 ex4],[a b a1 b1 c1 c2])
a*x^ex1 + b*y^ex2 = c1 (1)
a1*x^ex3 + b1*y^ex4 = c2 (2)
i.e.
>> z=symsolvesimulv2([1 1 2 2],[2 3 4 5 8 24]);
2 x + 3 y = 8
2 2
4 x + 5 y = 24
>> z
z =
[ 1, 2]
[ 13/7, 10/7]
These are the solutions for the 2 equations i.e. x = 1, y=2,
x=13/7, y = 10/7.
----------------------------------------------------------------
The code I wrote for 'solvesimulv2' is attached. Save it to your working folder and run as above.
引用格式
Bruce Raine (2024). Solving non-linear (and linear) simultaneous equations with 'solve' - version 2 (https://www.mathworks.com/matlabcentral/fileexchange/26313-solving-non-linear-and-linear-simultaneous-equations-with-solve-version-2), MATLAB Central File Exchange. 检索时间: .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0.0 |