Calling functions from other functions

2 visualizaciones (últimos 30 días)
KV
KV el 21 de Mzo. de 2013
Hi, I am developing a simple GUI. When a user presses a button, I want the code to initiate the curve fitting. I hae one function for GUI, and was looking to use another function which contains code for curve fitting, and the curve fitting tool function is called from GUI function. The code I have is below:
function hit_ok_Callback(hObject, eventdata, handles);
createFit(x, y);
end
function createFit(x, y)
ft = fittype ('poly4');
n[xdata, ydata] = prepareCurveData(x, y);
c = fit(xdata,ydata,ft);
However i get error saying i am using undefined function or variable. "Error in test>hit_ok_Callback. createFit(x, y)"
If I call the file containing just createFit function from command window, it works fine. What am I doing wrong in the way I am calling the function?
  2 comentarios
KV
KV el 21 de Mzo. de 2013
Anyone?
Jan
Jan el 21 de Mzo. de 2013
Editada: Jan el 21 de Mzo. de 2013
A bumping after 1 hour is not friendly. When the readers do not know an answer, reading the question again is a waste of time only. I suggest to limit bumping on more than 24 hours.
Please post a copy of the message, because paraphrased messages usually loose important details.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 21 de Mzo. de 2013
Editada: Jan el 21 de Mzo. de 2013
In this command:
createFit(x, y)
you get the message "undefined function or variable", but in the command window, this command works.
Then I guess, that createFit is a well known function, but x and/or y are not. The function header function hit_ok_Callback(hObject, eventdata, handles) does not contain these variables, but perhaps it is a nested function and you forgot to explain this. But even then, these variables are not declared according to the error message.
  1 comentario
KV
KV el 21 de Mzo. de 2013
Hi Jan, thanks for your response. It is not a nested function. I did try declaring x and y as input arguments in function hit_ok_callback as well but i get the error: Error using test>hit_ok_Callback Not enough input arguments.

Iniciar sesión para comentar.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by