matlab - How to use user-created class in Guide-created GUI -


i creating application in guide. i've found using "handles" structure provided guide store data leads messy/hard read code. decided best solution create own class handle data store methods used in callback functions. i've been able call constructor method in "annotatorgui_openingfcn" (seen below), when call class method in different callback function, can't find reference class. furthermore, line "annotatorengine = ...." underlined in yellow statement "value assigned variable might unused". seems class declaration doesn't propagate throughout entire gui script. want avoid using "handles" structure or declaring "annotatorengine" global. thanks!

edit: far seems thing has worked declaring class object global. however, still annoying because in each callback, have write "global annotatorengine".

% --- executes before annotatorgui made visible. function annotatorgui_openingfcn(hobject, eventdata, handles, varargin) % function has no output args, see outputfcn. % hobject    handle figure % eventdata  reserved - defined in future version of matlab % handles    structure handles , user data (see guidata) % varargin   command line arguments annotatorgui (see varargin)  % choose default command line output annotatorgui handles.output = hobject;  % update handles structure guidata(hobject, handles);  % class constructed here  annotatorengine = annotatorguiclass(handles.rawaxes, handles.psdaxes, handles.allpairsaxes)   % uiwait makes annotatorgui wait user response (see uiresume) % uiwait(handles.figure1); 

place call method.

% -------------------------------------------------------------------- function loaddata_callback(hobject, eventdata, handles) % hobject    handle loaddata (see gcbo) % eventdata  reserved - defined in future version of matlab % handles    structure handles , user data (see guidata)  [filename, pathname] = uigetfile('*.mat', 'select data file load'); annotatorengine.loaddata(filename, pathname)    return  


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -