A gentle introduction of polyfit in MatLab

Polyfit is a function name in MatLab language. In MatLab, the polyfit() function finds all coefficients from a polynomial equation. The polynomial equation consists of the degree n of x and y coordinate points. The x, y coordinates should be the same size for the fitting process. Polyfit also means, 'polynomial curve fitting'.
What is polynomial?
A polynomial is the expression of some consecutive terms, where the terms involve only arithmetical operations (addition, subtraction, multiplication). The form of the terms should be like this,
N.X^n
Where N is a number, X is the exponential variable and n is a positive integer. The n is also called as degree value of exponential variable X.

Problem-solving using polyfit in Matlab
Fit the sine function using polyfit in MatLab

Fit the cosine function and find the error using polyfit in MatLab

Fit the equation curve using polyfit in MatLab

Fit the equation curve and find the error using polyfit in MatLab