As we know, there are many ways to do the curve fitting such as ploynomial, expotential methods.However, we only have six weeks to do the project, so there may have no time to find the best way to generate a perfect curve. In this case, we will use the simplest way. First, i tried the polynomial functions which is inside of the matlab library called polyfit. This function will generate the coefiicients of the polynomial by different order. For example, if there are some dicrecte point, it could be represent by the equation y= a1+a2x+a3x^2+........+anx^(n+1). By this function, we could get the equation quickly. Then, there is a preblem, it is not sure about how many points for the curve and it can not determin the orders and if the order is higher, it will waste a lot of time or memory. As a result, I chooice a simple way. First, choose the first three points and do the curvefitting, then draw the line with the result between the first two points. Next, move another three points and do like this untill the last point. By this way, we do not need to care about how much data are input and save a lot of time. Here is a example:
If we input x and y:
Then we use curvefitting function:
From the figure, it shows that the curve we get pass through all the points. However, there still a problem that the curve is not extrem smooth as there is a peek in the third points.
We could also choose the range we want:



No comments:
Post a Comment