Hello,
Comments added below to code. You can see details of functions such as sort() by looking under the Origin C Lanaguage Reference help file, under the section Global Function->Analysis.
Easwar
OriginLab
// curve here referes to the pair of x,y fit dataset
// note that the x_y_curve is a copy of the original fit data set
// so any such change made to the curve does not change the original data
//
// sort the curve so that x values are in ascending order
sort( x_y_curve );
// smooth the curve using adjacent averaging to remove noise
smooth( x_y_curve );
// declare a dataset to obtain the x values of the curve
Dataset dx;
// and attach it to the x part of the fit data curve
x_y_curve.AttachX(dx);
// convert x to log of x to change the scale
dx = ln(dx);
// convert the y values of curve to log of y
x_y_curve = ln( x_y_curve );
// now perform a linear fit of the transformed x,y curve
double coeff[2];
fitpoly( x_y_curve, 1, coeff);
// assign the offset value of the linear fit to parameter a
a = exp( coeff[0] );
// assign the intercept value of the linear fit to parameter b
b = coeff[1];
// end of initialization - now parameter a and b have values