大型非线性解方程组建立与求解。
13 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
小弟现正在编一个求解大型非线性方程组的程序。在建立方程组的过程中遇到一些问题。
比如求:
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 commentaire
Réponse acceptée
rofiyw
le 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
可以考虑用数值解法
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!