_matlab Techniques for solving nonlinear equations with fsolve function

Source: Internet
Author: User
For the nonlinear Equation Group f (X) = 0, the numerical solution is obtained by fsolve function. The call format for the Fsolve function is: x=fsolve (' fun ', x0,option) where X is the returned solution, and the fun is the function file name for the nonlinear equations that define the solution of the demand, X0 is the initial value of the root process, and option is set for the Optimization Toolbox options. The Optimization Toolbox provides more than 20 options that users can use the Optimset command to display. If you want to change one of these options, you can call the Optimset () function to complete it. For example, the display option determines how intermediate results are displayed when a function is called, where ' off ' is not displayed, ' ITER ' means each step shows that ' final ' only shows the final result. Optimset (' Display ', ' off ') will set the Display option to ' off '. The numerical solution of the following nonlinear equations is obtained by example (0.5,0.5). (1) Establish function file MYFUN.M. function Q=myfun (P) x=p (1); Y=p (2); Q (1) =x-0.6*sin (x) -0.3*cos (y); Q (2) =y-0.6*cos (x) +0.3*sin (y); (2) Under the given initial value x0=0.5,y0=0.5, the Fsolve function is invoked to find the root of the equation. X=fsolve (' Myfun ', [0.5,0.5],optimset (' Display ', ' off ')) x = 0.6354 0.3734 will be the Jie back to the original equation, can verify the result is correct, the order is as follows: Q=myfun (x) q = 1.0e-009 * 0.2375 0.2957 can be seen with higher precision results. Note: in MATLAB, when using the Fsolve function definition, the variables and variables, except the addition and subtraction of operations such as "*,/,^" and other symbols should be preceded by ".", similar to the matrix or vector point multiplication, otherwise the optimal operation can not be carried out, and the system does not prompt error.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.