custom curve fitting with exponential or polynome

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

custom curve fitting with exponential or polynome

Post by strobbekoen » Mon Apr 23, 2012 9:51 am

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

Yeray
Site Admin
Site Admin
Posts: 9540
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: custom curve fitting with exponential or polynome

Post by Yeray » Mon Apr 23, 2012 11:43 am

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?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

Re: custom curve fitting with exponential or polynome

Post by strobbekoen » Mon Apr 23, 2012 12:41 pm

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).

strobbekoen
Newbie
Newbie
Posts: 23
Joined: Tue Feb 10, 2009 12:00 am

Re: custom curve fitting with exponential or polynome

Post by strobbekoen » Tue Apr 24, 2012 10:06 am

Any ideas ? :)
thank you

Yeray
Site Admin
Site Admin
Posts: 9540
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: custom curve fitting with exponential or polynome

Post by Yeray » Wed Apr 25, 2012 10:30 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply