Matlab learning data [6] & interpolation curve fit (fine)

First, the interpolation operation

In general, from a variety of data obtained by tests always have a certain amount , the interpolation technique is able to acquire the state of the whole system from limited data , and therefore, data interpolation in all walks of life, especially with the signal processing wide range of applications.

MATLAB provides functions for a variety of commonly used data interpolation calculations -
Alt
Note: the more common is the basic interpolation function interp series. And wherein interp1 interp1q comparison function, which is a monotonically increasing vector, Y is a column vector X, or in the process when the number of lines with the interpolated X matrix vector length, faster, and only linear interpolation.
★ interp1 function as general usage

interp1 = Yi (X, y, XI, Method)
% wherein: x and y are the original data. xi is the interpolation points to be calculated.

We can calculate the corresponding method is designated as interpolation algorithm, a string, whose value may be nearest, linear, spline, cubic, pchip, v5cubic.
Interp function in series, several different values of the parameters corresponding method different interpolation calculation method. Linear interpolation algorithm, for example, a linear, it is the system default interpolation algorithm, the spline interpolation a cubic spline algorithm.

% Specific operations online self-study, where ppt not read ...

Second, the curve fitting

Curve fitting requires derived from a number of discrete data in the mathematical analysis of the relationship between the two , andData interpolation is to calculate the number of new discrete data points through the raw data.
Alt
FIG print the original data -
Alt
Alt
Alt
Alt
Alt
in addition to the polynomial,You can also guess polynomial of the original data is composed by an exponential function
Alt
Thus, in order to obtain coefficients, the instructions can type the following MATLAB command line:

X = [ones(size(t)) exp(-t) t.*exp(-t)]
A = X\y

It should thus obtained polynomial:
Alt
Alt
Alt
two examples of the above comparison can be seen -In the curve fitting results of the two, using the exponential function fitting better results. So choose fitting result of the exponential function!

In addition, there is a method of curve fitting polynomial .
In MATLAB, a polynomial fitting using two main functions: polyfit and polyval.

polyfit function is mainly used for the fitting calculation, its basic syntax is

polyfit = P (X, y, n-)
% where, x and y are involved in raw data curve fitting calculation, n is an polynomial fit calculation, the return value is a function of coefficients of the polynomial, i.e., the function the calculation result polynomial coefficient vector.

Alt

Released nine original articles · won praise 6 · views 2102

Guess you like

Origin blog.csdn.net/RickieLim/article/details/104304997