Current location - Trademark Inquiry Complete Network - Futures platform - Given a set of data, how to predict future data with MATLAB.
Given a set of data, how to predict future data with MATLAB.
Like this:

x=)

Extended data:

Matters needing attention

The function command is:

A=polyfit(x, y, m)% x, y is the corresponding independent variable, and m is the highest power to be fitted.

y=polyval(a,x); ? % According to the fitted function, the value of the dependent variable corresponding to x is obtained.

The expression of the function is f (x) = a1* xm+...+am * x+a _ m+1.

Polyfit(x, y, n), where: x, y are vectors of known data points, representing abscissa and ordinate respectively, and n is the degree of fitting polynomial, and the result returns fitting polynomial coefficients of m degrees, which are stored in vector p from high order to low order. Parameter p is a fitting polynomial y = A 1x n+...+ANX+A, totaling n+6550.

Example:

% polynomial fitting

x =(0:0. 1:7)';

y = sin(x);

P = polyfit(x, y, 3) %p is the polynomial coefficient after fitting.

z=polyval(p,x);

plot(x,y,' r ',x,z,' b ')

Where p is the polynomial coefficient after fitting, and the running result is:

p = 0.0736-0.7095 1.5250-0.0296