How to build a graphical tool to compare several nonlinear fitting models
2 views (last 30 days)
Show older comments
Hello,
I would like to know which is the best tool for trying to organise my fitting procedure to experimental data Y(x,z). I have many sets of data Y(x,z) with errors, see example in figure where Y(x) is plotted for 3 values of z.
The number of x points changes with z, therefore the sets of data cannot be written as a matrix except if I do not fill with zero the missing points.
Then, I decide to make a separate fit for each z (even if in principle a surface fit to the whole set of data would be preferable).
I need to get the errors on the parameters p and I am using lsqcurve fit, and to test many different models, one example is the following:
Model_1= p(1) * (Ymodel conv Gaussian) + p(2)*Y1 +p(3) + p(4)*x
where:
Ymodel = f(T)*p(5)*p(6)^2 ./ ( (x.^2-p(6)^2).^2 + 4*(p(5) * x).^2 )
Ymodel is convoluted with a Gaussian with a given sigma
Y1: input set of data (same dimension of Y
where f(T) is a known function of the temperature T.
The goal is to obtain Ymodel. In all cases Ymodel must be convoluted with a Gaussian when fitting.
External data (Y1 in the example above) may be inclued, with an amplitude being a parameter of the fit (p(2) in the example above).
The model may have a varying number of parameter.
The models are defined in external function, for instance:
function [y,yM,y_noC,yD]=DHO2_R_BL(p,x,sig,f1,f2,Weight,Y1,T), where
p: fit parameters
sig=sigma of the Gaussian
f1, f2: parameters related to the convolution
Weight: 1/errors^2
The function above extracts some components of the model (model with and without convolution for example).
I then need to export parameters with an estimation of their errors (using nparci), and I also calculate the reduced chi square
My functions work (at least it looks like...), but given the high number of data and models, I would like to use some graphical interface to compare more efficiently the different models.
Ideally, I would be able to open two (or more) windows similar to the basic hand-made sketch here shown, in order to compare models and results.
What I am looking for is probably not very different from what produced by cftool, but with lsqcurvefit, conolution, external data....
I have no experience in GUI: could you give me some hints on the best way to tackle this problem?
Thank you in advance,
nando
0 Comments
Accepted Answer
Lama Itani
on 23 Nov 2021
Hi Ferdi,
Maybe you can give MATLAB App Designer a try.
It's an interactive tool that can let you build apps in MATLAB by dragging and dropping visual components. Here's a short video about the app designer: : https://www.mathworks.com/videos/app-designer-overview-1510748719083.html
2 Comments
Lama Itani
on 25 Nov 2021
If your script is working properly, it won't take you long to set up it up in App Designer. You'll be surprised by how easy it is to get started.
More Answers (0)
See Also
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!