Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
Why are the results to the fit command getting cleared from the workspace?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have attached 2 m-files. The 1st one calls on the 2nd one to generate a Fourier series curve fit. When I run it it terminates with the following error:
Reference to non-existent field 'R2'.
Error in FriedlanderFourierSeries2 (line 30) fitstats=[gof.sse gof.R2 gof.adjustedR2 gof.stdError];
It appears that the 2 workspace variables fitresult & gof get cleared out & I do not understand why. I figured this out by setting a breakpoint on line 30 & 33 of FriedlanderFourierSeries2.m. Both variables are visible in the workspace & when I continue they disappear. How do I hold onto those 2 variables?
0 commentaires
Réponses (1)
Mukul Rao
le 4 Déc 2017
Hi Jeff, the function "FriedlanderFourierSeries2" does not run to completion because of the error. Therefore, it does not return the output and clears variables in its scope, which includes "fitresult" and "gof".
The cause of the error is the expression "gof.R2", "R2" is not a valid field in "gof". You can either check if "R2" or another string is a valid field of "gof" using the isfield function. You can also use a try-catch statement around the "fitstats = ... " command.
A workaround, that you can consider, but which I would not strongly recommend is to use the assignin command right after you compute the fit and push these variables to the base workspace.
1 commentaire
Cette question est clôturée.
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!