classdef SingletonClass < handle methods(Access = private) function obj = SingletonClass() disp('SingletonClass construtor called!'); end end methods(... ...
classdef SingletonClass < handle methods(Access = private) function obj = SingletonClass() disp('SingletonClass construtor called!'); end end methods(Static) function obj = getIns() persistent ins; if isempty(ins) || ~isvalid(ins) ins = SingletonClass(); end obj = ins; end end end