Pass 'cfit' object into a new function
10 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Tom Lane
on 20 Mar 2013
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?
0 Comments
See Also
Categories
Find more on Linear and Nonlinear Regression in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!