Pass 'cfit' object into a new function

조회 수: 5 (최근 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