MATLAB curve Fitting

Source: Internet
Author: User


The MATLAB software provides the basic curve fitting function commands.



polynomial function Fitting :

 A=polyfit (xdata,ydata,n)



where n represents the highest order of the polynomial, xdata,ydata is the data to be fitted, which is entered as an array. The output parameter A is the coefficient of the fitted polynomial



The value y of the polynomial at x can be calculated using the program below.



Y=polyval (a,x)



General curve Fitting

P=curvefit (' fun ', p0,xdata,ydata)



Where fun represents the function fun (p,data) m function file, P0 represents the initial value of the function. The Curvefit () command solves the problem in the form of






To solve the function value at point x, the program F=fun (P,X) calculation is available.



For example known function form, and known quantity point to determine four unknown parameter a,b,c,d.



Use the Curvefit command, data entry, initial value loss, and the M file (fun) that establishes the function. m). If defined, the output



And as an example of the solution, MATLAB program:



T=[L:16];% Data output person



Y=[4 6. 4 8 8. 4 9. 28 9. 5 9. 7 9. 86 10. 2 10. 32 10. 42 10. 5 10. 55 10. 58 10. 6];



Plot (t,y, ' o ')% draw scatter plot



P=polyfit (t,y,2) (two-time polynomial-fitting)



Calculation Result:



p=-0.0445 1.0711 4.3252 two-polynomial coefficients



Thus the fitting function of the concentration y and time t of a compound is obtained.






How is the accuracy of the function detected? The scatter and fit curves are still detected graphically on a single screen. See Figure 5.3.









Thus, it is found that the above curve fitting is quite consistent.



**********************************************************************



do: with the same data, if the fitting curve is assumed, try to compare the fitting curve with the above fitted curve, and how accurate it is.



Note:

What is the difference between curve fitting and curve interpolation.



MATLAB program



where the ' + ' is the known quantity stronghold, the solid line connecting the data points is the linear interpolation function curve, and the smooth function curve is the best fit curve. It is explained that there are two typical methods for describing known quantity points using analytic functions-interpolation and fitting



**********************************************************************



think

Matlab software in the surface fitting another how to do it.




The Polyfit and lsqcurvefit of Matlab only give the result of fitting the parameters to the data, and do not give the error.



Refer to Matlab function Nlparci, can calculate the confidence interval of the parameter fitting.



**********************************************************************



In the Nag Foundation Toolbox of MATLAB, there are also some surface fitting functions, such as E02DAF is the least squares square surface fitting function, e02def can find the function value of surface fitting.



The fundamentals of surface fitting are described in the book on numerical analysis, which is not much more.



Note: Help information can be found in the function form, description, and application examples in the Nag Foundation Toolbox in MATLAB. For example, typing help E02DAF will show a more detailed description of the function E02daf. Adding e to the end of the function is an example of an application, such as typing type E02DAF, which shows the application example of the function E02daf, typing E02DAF, running the program, and displaying its calculation results.





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.