1

Possible Duplicate:
Global (shared) variables in Matlab GUI code behind. Is there better way to do it then using handles structure?

I couldn't find any information about it, this is what I want to archive.

I want to create GUI classes similar to standard Windows OOP. For example I want to create a class representing a window which would contain definitions of children objects such as buttons, lists and so on.

I would create that object in the main .m file and go from there. Is something like that possible in MATLAB? If not, which approach should I have?

Can you give me a simple code from where I would start, e.g. a class definition for a simple window and a main .m file declaring it.

Community
  • 1
  • 1
Vladimir
  • 574
  • 1
  • 6
  • 17

1 Answers1

1

------ FigGUI.m --------

classdef FigGUI < handle
    properties
        fig
    end
    methods
        function obj = FigGUI(varargin)
            obj.fig = figure(varargin{:});
        end
        function clear_figure(obj)
            clf(obj.fig);
        end
        % ... more methods
    end
end

Construction example:

f = FigGUI('Position', [560   528   560   420], 'Name', 'GUI');
f.clear_figure();

... and so on

Serg
  • 13,470
  • 8
  • 36
  • 47