How to extract coefficients from from curve fitting tool?
134 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Benjamin
el 10 de Dic. de 2020
Comentada: sebastian ruiz
el 20 de Dic. de 2021
Hello everyone,
I used Curve Fitting Tool in MATLAB and fitted a curve to some data points. Then generate the code and used it as a function as a part of my program. However, when the results show up, they are not stored in a cell or struct to be used later in the program. I am especifically refering to the model fit coefficients which is the output of the curve fitting function.
Does anybody know a way to extract the model fit coefficients.
Here I attached the program. By running the program the model fit (coefficients a and i) will be shown (as picture bellow), but not stored/saved in the workspace.
I appreciate your responses in advance
1 comentario
sebastian ruiz
el 20 de Dic. de 2021
Greetings,
In case it is still good for you.
The output from a cftool will be a *.sfit
so for example,
fit001.sfit % your output and you want the goodness RMSEs
then while on that folder,
for i = 1:length
fit001_rmse(:,i) = fit001.AllFitdevsAndConfigs{i,1}.Fitdev.Goodness.rmse;
end
Respuesta aceptada
John D'Errico
el 10 de Dic. de 2020
Editada: John D'Errico
el 10 de Dic. de 2020
Simply enough. In fact, they ARE stored in the workspace. They are just not returned as separate variables. And that is a good thing. Extracting them is trivial though.
x = rand(10,1);
y = randn(10,1);
g1 = fit(x,y,'power1')
g1.a
g1.b
Or, if you wish to extract them as a vector of coefficients, just do
format long g
coeffvalues(g1)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!