大型非线性解方程组建立与求解。

14 views (last 30 days)
recipac
recipac on 24 Nov 2022
Commented: Sunglin on 24 Mar 2025
小弟现正在编一个求解大型非线性方程组的程序。在建立方程组的过程中遇到一些问题。
比如求:
equ1='u1^2+u2^2+u1*u2=1'
equ2='u2^2+u3^2+u2*u3=2'
equ3='u3^2+u4^2+u3*u4=3'
..........
equn='un^2+u1^2+u1*un=n'
solve(equ1,equ2,equ3,....equn,'u1','u2',u3'....'un')
从而得出u1,u2,u3....un值。
如果n很大,一个一个编写equ1,equ2,equ3....equn肯定很麻烦,sovle()内的内容也肯定会很大很冗长,可不可以通过循环语句或其它方法来实现以上问题程序编写。望高手指点!!!
  1 Comment
mingyang
mingyang on 29 Nov 2022
你好,请问该问题解决了吗?我最近也遇到需要求解大型非线性方程组的问题了

Sign in to comment.

Accepted Answer

rofiyw
rofiyw on 24 Nov 2022
之前没有仔细看,以为你的最后一个式子中用的是u_n+1
你这个方程如果一定要用solve解的话,对于比较大的n会非常慢:
n = 5;
eqs = sprintfc('u%d^2+u%d^2+u%d*u%d=%d',[1:n;[2:n 1];1:n;[2:n 1];1:n]');
vars = sprintfc('u%d',1:n);
sol = solve(eqs{:});
sol.u1
可以考虑用数值解法
  1 Comment
Sunglin
Sunglin on 24 Mar 2025
有什么针对大型非线性方程组的解法吗

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!