最近有人问我matlab求解方程组的问题,
下面提供了fsolve函数help,但要有几点需要注意
1.方程组的有解性
2.方程组解是否唯一
3.x0的选取,如果解不唯一,不同的x0可能会得到不同的解
fsolve - Solve system of nonlinear equations
Equation
Solves a problem specified by
F(x) = 0
for x, where x is a vector and F(x) is a function that returns a vector value.
Syntax
x = fsolve(fun,x0)
x = fsolve(fun,x0,options)
x = fsolve(problem)
[x,fval] = fsolve(fun,x0)
[x,fval,exitflag] = fsolve(...)
[x,fval,exitflag,output] = fsolve(...)
[x,fval,exitflag,output,jacobian] = fsolve(...)
Description
fsolve finds a root (zero) of a system of nonlinear equations.
x = fsolve(fun,x0) starts at x0 and tries to solve the equations described in fun.
x = fsolve(fun,x0,options) solves the equations with the optimization options specified in the structure options. Use optimset to set these options.
x = fsolve(problem) solves problem, where problem is a structure described in Input Arguments.
Create the structure problem by exporting a problem from Optimization Tool, as described in Exporting to the MATLAB® Workspace.
[x,fval] = fsolve(fun,x0) returns the value of the objective function fun at the solution x.
[x,fval,exitflag] = fsolve(...) returns a value exitflag that describes the exit condition.
[x,fval,exitflag,output] = fsolve(...) returns a structure output that contains information about the optimization.
[x,fval,exitflag,output,jacobian] = fsolve(...) returns the Jacobian of fun at the solution x.
Passing Extra Parameters explains how to parameterize the objective function fun, if necessary.
Input Arguments
Function Arguments contains general descriptions of arguments passed into fsolve. This section provides function-specific details for fun and problem:
| The nonlinear system of equations to solve. fun is a function that accepts a vector x and returns a vector F, the nonlinear equations evaluated at x. The function fun can be specified as a function handle for an M-file function x = fsolve(@myfun,x0) where myfun is a MATLAB® function such as function F = myfun(x) F = ... % Compute function values at x fun can also be a function handle for an anonymous function. x = fsolve(@(x)sin(x.*x),x0); If the user-defined values for x and F are matrices, they are converted to a vector using linear indexing. If the Jacobian can also be computed and the Jacobian option is 'on', set by options = optimset('Jacobian','on')
then the function fun must return, in a second output argument, the Jacobian value J, a matrix, at x. If fun returns a vector (matrix) of m components and x has length n, where n is the length of x0, then the Jacobian J is an m-by-n matrix where J(i,j) is the partial derivative of F(i) with respect to x(j). (Note that the Jacobian J is the transpose of the gradient of F.) |
||
| problem | objective |
Objective function |
| x0 |
Initial point for x | |
| solver |
'fsolve' | |
| options |
Options structure created with optimset | |
Output Arguments
Function Arguments contains general descriptions of arguments returned by fsolve. For more information on the output headings for fsolve, see Function-Specific Output Headings.
This section provides function-specific details for exitflag and output:
| exitflag |
Integer identifying the reason the algorithm terminated. The following lists the values of exitflag and the corresponding reasons the algorithm terminated. |
|

fsolve是MATLAB中用于求解非线性方程组的函数,它寻找使F(x)=0成立的解。本文介绍了fsolve的用法、语法、选项,并给出两个示例,强调了解决方程组时需考虑方程组的有解性、解的唯一性和初始猜测值的选择。fsolve采用Gauss-Newton、Levenberg-Marquardt等算法,适用于中大规模问题。

2294

被折叠的 条评论
为什么被折叠?



