fit multiple curves with external parameters (lsqcurvefit)
Show older comments
Hello,
It's been a while I am looking of a way to pass extra parameters to a fitted function together with fitting a single model to several data sets. I have come with a solution that looks very convenient to me but I wonder if there are issues that I am not aware of. Please excuse me if this has been already asked many times.
I use the lsqcurvefit function from the optimization toolbox and proceed as follow:
[output]=lsqcurvefit(@model, x0, Xdata, Ydata, ...)
where, instead of having Xdata a vector, I pass a matrix. It appears that only the first column of the matrix Xdata is used for the optimization of the least square problem and so I use additional column to pass extra parameters.
Example: I need to fit a single model to a serie of curves that correspond to different external magnetic field strength. I thus need to also pass the magnetic field strength for each data point to my function "model". I then simply create the matrix.
Xdata=[x11, b11 ;
x12, b12;
...
x21, b21;
x22, b22;
... ];
YData=[y11; y12; ... ;y21; y22; ...];
where xij denotes the jth data point of the ith dataset and b a parameter (magnetic field, dataset tag, ...). This is typically very convenient to use dataset tag to handle data set with different length.
My questions are: Is this leading to some problems for the optimization process? Does that influence the confidence interval of my fitting parameters? Is there any known issues with passing a Xdata matrix instead of a vector? I have tried on my datasets, it looks fine, but I want to make sure that everything is right...
Many thanks in advance for your replies,
Vincent
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!