15.3.4.4.1 A Simple Example

Contents

Summary

This tutorial will show you how to create a fitting function with the Fitting Function Builder.

Minimum Origin Version Required: Origin 8.5 SR0

What you will learn


Steps

  1. In Origin's main menu, click Tools, and then click Fitting Function Builder to open the tool. Click Create a New Function on the first (Goal) page, and then click Next to go to the Name and Type page.
  2. On the Name and Type page, we will create a category for the new fitting function, then name the function and select a Function Type.
  3. On the Variables and Parameters page, we will do the following:
  4. On the Function Body page, we will input the function body and choose the peak attribute for each parameter.
    double B,sig;
    B=A/(0.5*(sig1+sig2)*sqrt(2*pi));
    sig = x<xc ? sig1:sig2;
    y = y0 + B * exp(-0.5 *((x-xc)/sig)^2);
    Ffb tutorial 5.png
  5. Click Next to go to the Parameter Initialization Code page, and enter the following codes into the Initialization Code edit box.
    double cent;
    double sig;
    xc = peak_pos(x_y_curve, &sig, &y0, NULL, &A, &cent);
    sig1 = 0.42466 * (sig - 2 * (cent-xc));
    sig2 = 0.42466 * (sig + 2 * (cent-xc));
    Ffb tutorial 7.png
  6. Click Next to go the Bounds and General Linear Constraints dialog, and then set the dialog as in the image below:
    Ffb tutorial 6.png
  7. Click Finish.
NOTE: To define a peak function available in Quick Peaks Gadget or Multiple Peak Fit tool, the user-defined peak function must be in the category of Peak Functions.

Where to Access the User-defined Function

  1. Use the user-defined function to perform curve fitting with the Nonlinear Fitter. For more details about the Nonlinear Fitter, please refer to Nonlinear Curve Fitting.
    Ffb tutorial 8.png
  2. Find the function in the Fitting Function Organizer. For more details about the Fitting Function Organizer, please refer to Fitting Function Organizer.
    Ffb tutorial 9.png
  3. In the Fitting Function Organizer, right-click this function and select Share To to share this function to the PFW category. You can then use the function to perform peak fitting with the Peak Analyzer.
    Ffb pafit.png