fsolve编辑本段回目录
求解非线性方程函数
[x,fval,exitflag,output,jacobian]= fsolve(fun,x0,options) 输入及其输出解释如下
输出:
x——零点值;
fval——x带入的最终的误差值
exitflag——迭代终结原因表示数:(1-收敛于x;2-x迭代误差小于指定值;3-fval迭代误差小于指定值;4-搜索方向的幅值小于指定值;0-迭代次数超过最指定数(Maxlter)或者fval超过指定值(Funs);-1-算法终止按照输出函数(output function);-2-貌似算法收敛于非零跟;-3-确信界限太小;-4-线性搜索方法不再适用)
output——迭代过程信息:(iterations-迭代次数,funccount-函数值、亦即每次的fval,algorithm-用的算法,cgiterations-PCG迭代数(只用于large-scale algorithm),stepsize-最终一步步长(只用于medium-scale algorithm),firstorderopt-一阶最优近似值(只用于large-scale algorithm))
jacobian——输出Jacobian矩阵值
输入:
fun——需要解的方程或方程组,简单可以直接引入,复杂要写成.m的函数形式
x0——迭代初始值
options——计算过程的指定参数,由optimset设定:
(1)LargeScale——是否采用 large-scale algorithm,'on'-'off'。(方程有定解时on)
The following options are used by both the medium-scale and large-scale algorithms
(2)DerivativeCheck——比较微分值,给出的Jacobian矩阵值和差分计算结果
(3)Diagnostics——函数诊断信息
(4)DiffMaxChange/DiffMinChange——有限差分时变量的最大最小变化
(5)Display——显示控制项:off -不显示,iter-每步显示,final-显示最后一步
(6)Jacobian——Jacobian输出控制项,on-用户定义的Jacobian矩阵值,off-有限差分代替 Matlab中文论坛
(7)FunValCheck——是否显示函数值违法信息( complex, Inf, or NaN)on-输出
(8)MaxFuns——Maximum number of function uations allowed
(9)MaxIter——Maximum number of iterations allowed
(10)TolFun——Termination tolerance on the function value 《Simulink与信号处理》
(11)TolX——Termination tolerance on x
(12)TypicalX——Typical x values
(13)OutputFcn ——函数执行的每步被调用的函数:odephas2(画出2D的平面相位图)。Odephas3(画出3D的平面相位图),odeplot(画出解的图形),odeprint(显示中间结果)