classdef BasicHandle < handle
properties
Prop1
end
methods
function obj = BasicHandle(val)
if nargin > 0
obj.Prop1 = val;
end
end
end
endCreate a BasicHandle object and use it in a switch statement:h1 = BasicHandle('Handle Object');
h2 = h1;Here is the switch statement code:switch h1
case h2
disp('h2 is selected')
otherwise
disp('h2 not selected')
endThe result is:h2 is selectedObject Must Be ScalarThe switch statements work only with scalar objects. For example:h1(1) = BasicHandle('Handle Object');
h1(2) = BasicHandle('Handle Object');
h1(3) = BasicHandle('Handle Object');
h2 = h1;switch h1
case h2
disp('h2 is selected')
otherwise
disp('h2 not selected')
end5 Class Definition—Syntax Reference