Page 1 of 1

custom curve fitting with exponential or polynome

Posted: Mon Apr 23, 2012 9:51 am
by 10051902
Hi,

I am trying to do a curve fitting, but I can't figure out how to use my own formula's for the fitting.

I need to provide 2 ways of curve fitting:
- using a exponentional function (see image below)
- using a polynome y=ax³+bx²+cx+d where i define the factors a to d

Once, the curve is plotted, I also need to some mathematical operations on it, e.g. calculating the tangent at a certain angle.

Is it possible to do such custom functions ?

Image

Image

Re: custom curve fitting with exponential or polynome

Posted: Mon Apr 23, 2012 11:43 am
by yeray
Hi,

Have you tried using the custom function as in the example at "All features\Welcome !\Functions\Extended\Custom y=f(x)" in the features demo program included with the binary installation?

Re: custom curve fitting with exponential or polynome

Posted: Mon Apr 23, 2012 12:41 pm
by 10051902
I think the y=f(x) is just a function to plot y-values as a function of x.
I have a chart which for example has 10 points.
I need to do a curve fitting with a polynome or a exponential function (2 methods for fitting).

Re: custom curve fitting with exponential or polynome

Posted: Tue Apr 24, 2012 10:06 am
by 10051902
Any ideas ? :)
thank you

Re: custom curve fitting with exponential or polynome

Posted: Wed Apr 25, 2012 10:30 am
by yeray
Hi,

The Curve fitting function calculates the polynomial factors that best matches the source data. I'd suggest you to take a look at the example in the features demo program at "All features\Welcome !\Functions\Extended\Cure fitting"
I think it would fit your polynome requirement.

Regarding the exponential function, I still think it should be done with the custom function. Here you have an example that looks similar to the one in your picture:

Code: Select all

var Line1: TLineSeries;
    CustomFun1: TCustomTeeFunction;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  CustomFun1:=TCustomTeeFunction.Create(Self);
  CustomFun1.StartX:=1.3;
  CustomFun1.Period:=0.001;
  CustomFun1.NumPoints:=125;
  CustomFun1.OnCalculate:=Calculate;

  Line1:=Chart1.AddSeries(TLineSeries)as TLineSeries;
  Line1.FunctionType:=CustomFun1;

  Chart1.Axes.Left.SetMinMax(0, 12);
  Chart1.Axes.Bottom.SetMinMax(1.28, 1.44);
end;

procedure TForm1.Calculate(Sender:TCustomTeeFunction; const x:Double; var y:Double);
begin
  y:=0.0000004 * Exp(11.939*x);
end;