get variables from one file to mainfunction in gui

2 次查看(过去 30 天)
Hi, i have main function in m.file, i want to callback some variables in main function that in the form of another m.file. how can i callback that m.file variables in main function, i used guidata(hObject,handles) it displays ??? Error using ==> popupmenu_Callback Too many output arguments.
Error in ==> SERC>popupmenu_Callback at 131 handles.popupmenu_callback = popupmenu_callback
Error in ==> gui_mainfcn at 97 feval(varargin{:});
Error in ==> SERC at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)SERC('popupmenu_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
what is the error in that....

回答(1 个)

Bob Hamans
Bob Hamans 2011-7-8
Just pass the variables between your function as an argument if you do not need intermediate action/calculation.
outvarfunc1 = func1(invarfunc1); outvarfunc2 = func2(outvarfunc1);
Or try to make use of the function assignin to assign a value to variable in a specified workspace of a caller function.
assignin('caller', 'invarfunc2', outvarfunc1);
Or if you want to get really dirty use a global variable.
global varinouteverywhere;

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by