Curve Fitting Toolbox: solution generated by the GUI not the same as the one generated by the line of codes (generating code)
Show older comments
I'm using the GUI coming with the curve fitting toolbox to help me generating a good fit.
I have a "shock damper" transfer function which ressemble somewhat a gaussian:
- value around 1 at "low frequency" (i.e. at low x-axis value the y-axis value is about 1)
- a peak at the "resonance frequency"
- a sharp decrease at "high frequency" toward 0 (i.e. at high x-axis value the y-axis value is closed to 0)
using then "Gaussian" with 5 terms on the GUI, I got a very good match between my datapoint.

notably the coefficient a1 = 0.5348
the fit option are left as standard. I'm not sure if the fact that the "fit computation did not converge" is the issue.
now when I use the option to "generate the code" and run it, I get a fitresult with other parameters.

notably the coefficient a1 = 0.4643
I checked all the options and parameters between the GUI and the generated code and they are identical.
and these changes as you can see under, lead to an actual less good fit at high frequency, with a curve that deviate with the general exponential decrease.

do you know why the GUI "converge" to a better solution than the generated code? how can I ensure to get the same solution with the generated code as with the GUI?
as a quick fix I will simply use in my code the coefficients I get from the GUI (hardcoding them), but I would like to be able to generate the same solution.
as it is with a GUI, I don't know how I should show the different details (i.e. it is not enough to simply copy the code). let me know what information you might need and I will provide it.
thank you for your assistance.
1 Comment
Bastien Haemmerli
on 13 Jun 2022
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with Curve Fitting Toolbox 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!