## Matlab Curve Fitting Tutorial

Curve fitting is the process of matching the pattern data in the form of a graph into an equation . The simple notion that changing the graphics data into an equation that can represent the graph. this can be done easily in matlab . follow the following tutorial:

1. Open matlab

2. prepare your chart data . if it does not have as an example here we create a data chart with the following equation .

type in the command windows matlab

x = -10 : 0.1 : 10 ;

y = x ^ .2 + 10 ;

make sure the workspace window there is a data x and y .

3. type

**cftool**to use matlab curve fitting , then you will see a dialog like the following illustration:

4. then select the x data with ' x ' and y data with ' y ' which we have generated by typing the equation above earlier . then the graph will automatically display the data in graphical form as shown below .

5. from the picture above we can see there are two lines , the color black is the data that we have , and the blue is estimated data with polynomial formula . of the graph we can see there is no match at all . then we find the formula or degree option available on the column polynomial

6. Let's first try to increase the degree of the polynomial into two . As a result as follows :

from the picture above shows the blue line resembles the outline of a black color , so that it can be said of this equation is appropriate to represent the equation y = x ^ .2 + 10 . The new equation we get we can see on the left side of the graph . as follows:

can be seen from the picture above the new equation that represents the graph , ie

y = p1 * x ^ 2 + x + p2 * p3

with the value of p1 , p2 , p3 as written above , by ignoring the very small value ie p2 . then we will get a new equation above becomes

y = x ^ 2 + 10 .. so the curve fitting equation is able to recognize up to 99 % .

y = p1 * x ^ 2 + x + p2 * p3

with the value of p1 , p2 , p3 as written above , by ignoring the very small value ie p2 . then we will get a new equation above becomes

y = x ^ 2 + 10 .. so the curve fitting equation is able to recognize up to 99 % .

to represent the data above , we do not have to use a polynomial equation , you can also try the exponential or Gaussian degree 2 equation , but the result is less good for the exponential gaussian results are compared with the second degree .

for exponential equations that represent the data is :

for exponential equations that represent the data is :

f(x) = a*exp(b*x) + c*exp(d*x)

Coefficients (with 95% confidence bounds):

a = 7.948 (7.274, 8.622)

b = -0.2705 (-0.2804, -0.2606)

c = 7.948 (7.275, 8.622)

d = 0.2705 (0.2606, 0.2804)

a = 7.948 (7.274, 8.622)

b = -0.2705 (-0.2804, -0.2606)

c = 7.948 (7.275, 8.622)

d = 0.2705 (0.2606, 0.2804)

and for gaussian is :

f(x) = a1*exp(-((x-b1)/c1)^2) + a2*exp(-((x-b2)/c2)^2)

Coefficients (with 95% confidence bounds):

a1 = 173.8 (168.3, 179.4)

b1 = 15.77 (15.5, 16.05)

c1 = 8.442 (8.306, 8.579)

a2 = 173.8 (168.3, 179.4)

b2 = -15.77 (-16.05, -15.5)

c2 = 8.442 (8.306, 8.579)

Good luck with your data .

Hopefully this article helps you , :)

## 0 comments:

## Post a Comment