is it possible to fit a varargin function?

2 views (last 30 days)
Cant Find
Cant Find on 7 Oct 2015
Answered: Star Strider on 7 Oct 2015
I have some discontinuous data which I want to piecewise fit all at once since there is one parameter of the fit which is common to all parts of the function. The number of discontinuities, and their places vary.
I thought about using a class and holding the discontinuity indices as a data member, and then using a member function with varying number of inputs to be the function I send to Matlab's fit function.
But apparently this does not work (varargin is empty if I use it directly inside nlfit, throws a long error message if I use it with fittype = ('funcName(x,A,B,C)')).
Any Ideas?

Answers (1)

Star Strider
Star Strider on 7 Oct 2015
So long as all the data represent the same general relationship (the function you want to fit), the order in which they are presented to the regression function, and any discontinuities in the data, are irrelevant to the regression function. It doesn’t care.
If you want to plot your data, you obviously need to sort them by ascending values of the independent variable, but that is the only restriction.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!