Info
此问题已关闭。 请重新打开它进行编辑或回答。
Why are the results to the fit command getting cleared from the workspace?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Mukul Rao
2017-12-4
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 个评论
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!