Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Why are the results to the fit command getting cleared from the workspace?

1 visualización (últimos 30 días)
Jeff
Jeff el 30 de Nov. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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?

Respuestas (1)

Mukul Rao
Mukul Rao el 4 de Dic. de 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.

La pregunta está cerrada.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by