I've been working on a GUI for a computing program in Matlab, that program is implemented in a Object-oriented manner. So I'm thinking how to integrate the GUI code created by GUIDE to the class to keep the conformity.
First I searched the Stackoverflow to find out the similar question, and then I got one Click.
I tried the method mentioned in that answer, and failed. So anyone could give me some more details and advise would be really helpful!
My code is orgnized like that:
classdef A < handle
methods
function obj = A(varargin)
%some code
end
function Aplot(obj,varargin)
%some code
obj.fh = Aview(obj)
end
function varargout = Aview(varargin)
% this is the code generated by GUIDE in a seperate file
% associated with AView_OpeningFcn(hObject, eventdata, handles, varargin)
% and component(edit, popupmenu,etc) callback functions
end
Then I got lots of error for every component(buttion,popupmenu) in windows, typically like this:
Undefined function 'AView' for input arguments of type 'char'.
Error in @(hObject,eventdata)AView('popupmenu1_CreateFcn',hObject,eventdata,guidata(hObject)
Error using struct2handle
Error while evaluating uicontrol CreateFcn
How can I successfully pass the object of class A to the GUI function AView window, in case I need some data structure inside object A?
Thanks in advance:)
More comments: I didn't copy the file generated by GUIDE into the Class A. But just put the GUIDE-generated in a folder which name is @A, as same as A.m. In this way, the function generated by GUIDE will be regard as the method of class A
Reference: search "Methods In Separate Files" in http://www.mathworks.com/help/matlab/matlab_oop/specifying-methods-and-functions.html#brqy3km-15