matlab-fsolve function calculation by nonlinear equation

Record the code for next apply the template

Options = optimset ( 'MaxFunEvals', 1E4, 'MaxIter', 1E4); 

[X, FVAL, exitflag] = the fsolve (@ (X) myfun1 (X), [75; for 1.5], Options) 

function F = myfun1 (X ) 
F = Tan (X (. 1) * PI / 180 [) - ((1025 * 9.8 * PI * X (2) / 4-980) / (0.625 * *. 4 (2-X (2)) * 24 * 24 ));% two unknowns x (1) and x (2), pass the parameter in the incoming 
end
options understood as the set requirements, the accuracy range, there is no default, is not much problem.

[75; 1.5] is the initial value x (1) and x (2), if the same number is different from the initial value [701; 75 1.5], to find the optimal solution in the vicinity of the initial value. To understand: there may be more optimal solution, if not the same as the initial value, the optimal solution is not the same. Almost all nonlinear approximate solution. As for how to set the initial value, combined with problem analysis, such as the tilt angle of the pole against the wall above about 60 degrees, rather than the ten to twenty degrees.

Solving the case myfun1 function is f = 0.

fval represents an error, the smaller the better.

exitflag represents the iteration exit criteria for the ideal time 1.

1 fsolve converged to a root.

2 Change in X too small.

3 Change in residual norm too small.

4 Computed search direction too small.

0 Too many function evaluations or iterations.

-1 Stopped by output/plot function.

-2 Converged to a point that is not a root.

-3 Trust region radius too small (Trust-region-dogleg).

Find out the final two values, respectively, two unknowns x (1) and x (2).

If multiple equations, generally linked, obtained after a request by a relative unknown equation else.

 

Guess you like

Origin www.cnblogs.com/shoulinniao/p/11440844.html
Recommended