Thursday, 8 December 2011

Matlab Basic fitting Example | Curve Fitting matlab Example

Cure Fitting is one of the Toolbox in matlab .Curve fitting used to draw our data points in different types of fittings.In curve fitting contain following fittings.
  1. Spline Interpolant
  2. Space-preserving Interpolant
  3. Quadratic
  4. Cubic
  5. 4th Degree Polynomial
  6. 5th Degree Polynomial
  7. 6th Degree Polynomial
  8. 7th Degree Polynomial
  9. 8th Degree Polynomial
  10. 9th Degree Polynomial
  11. 10th Degree Polynomial
The above type of polyfiting are there in matlab.

In below example to use the poly fitting in our data s.

>> xdata1 = 1:10;
>> ydata1 = rand(1,10);

>> axesLimits1 = [min(xdata1) max(xdata1)];
>> xplot1 = linspace(axesLimits1(1), axesLimits1(2));
>> fitResults1 = polyfit(xdata1, ydata1, 1);
>> yplot1 = polyval(fitResults1, xplot1);
>> figure;plot(xplot1,yplot1,'color','red')
>> hold on;
>> drawnow;
>> plot(xdata1,ydata1);

Here we getting xdata and ydata,then we find minimum limit and maximum limit of xdata,then find out linspace ,then find the polyfitting use 1.1 means linear fitting,if You have change that number you get different poly fitting.The out put as follows.



Kindly Bookmark and Share it:

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...