Hi Herbert,
UserFunction is an Interface, you have to implement it:
public class MyPlugin implements UserFunction{
...class variables
...methods, including, e.g.,
CurveFitter fitter = new CurveFitter(xData, yData);
fitter.doCustomFit(this, //'this' refers to the instance of MyPlugin
//thus the CurveFitter will call the
//userFunction of MyPlugin
numParams, "my super fit, initialParams,
initialParamVariations, showSettings);
public double userFunction(double[] par, double x) {
return par[0]*x + par[1]*x*x*x; //your function
}
}
Michael
________________________________________________________________
On Nov 23, 2012, at 18:22, Herbert Fan wrote:
> Hello,
>
> I encountered problems trying to use the CurveFitter method doCustomFit (UserFunction userFunction, int numParams, String formula, double [] initialParams, double [] initialParamVariations, boolean showSettings). I have an issue trying to pass a valid argument as userFunction, because UserFunction is an abstract class and cannot be instantiated. Furthermore, error messages show that only ij.measure.UserFunction reference variables are accepted, not any UserFunction variable implemented within my own plugin class.
>
> I would think that the doCustomFit method requires me to somehow transform my custom-written function within the userFunction (double [] params, double x) method (method signature of the interface UserFunction) into a UserFunction-type variable object. I don't see how that is possible, but maybe I am missing something.
>
> Thank you!
> Herbert
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html