Pass 'cfit' object into a new function

10 次查看(过去 30 天)
Cullen
Cullen 2013-3-19
I am developing a GUI where I ask the user what data they want to regress, and to select the functional form of the data regression. The GUI will then gather the correct data, and regress the data using the fit() function. This will generate a cfit class variable. This is what I have working.
Next I would like to be able to take the regression of that data and pass it into a separate function so that I can manipulate it.
Simply it can be described as follows:
X = [];
Y = [];
regression = fit(X, Y, FitType, opts);
[new_line] = ModifyLine(X, Y, regression)
When I try to run the code as show above I get the Error:
Undefined function 'File_Name' for input arguments of type
'cfit'.
My regression function is properly formatted because I am able to plot the data and the regression at the end of the function.
I know I could generate the fit function as a sub function to ModifyLine however this would start to require me to pass in and out an excessive number variables.
Does anyone know how to pass a cfit type into a function? or a way to bypass the pass through statement and directly import from the other function?
Thanks

回答(1 个)

Tom Lane
Tom Lane 2013-3-20
You appear to be assigning [] to both X and Y, then fitting to that. I wouldn't expect that to work.
However, if you are successful in creating the regression variable, you should be able to pass it into another function. The error message complains that it can't find a function called File_Name. Are you trying to call such a function from inside ModifyLine, and do you have a File_Name function on your path?

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by