Why can't I use the object that the uicontrol creates within a class created GUI?

3 views (last 30 days)
I need to use the variable created in the callback function, but anytime I try, I get an error saying that I'm pretty much trying to convert an instance of my class to a number. Is it an issue with the get function or of the uicontrol within a class?
classdef LaserFilterTest < handle
properties
fig;
title_405;
menu_405;
end
properties(Access = private)
callback_405;
end
methods
function obj = LaserFilterTest()
obj.fig = figure;
obj.callback_405 = @setpos3;
obj.title_405 = uicontrol(obj.fig, 'Style', 'text', ...
'String','405 Laser','Position', [20 350 100 20]);
obj.menu_405 = uicontrol(obj.fig,'Style','popup', ...
'String', '100%|50%|25%|10%|5%|1%', ...
'Position', [20 300 100 50], ...
'Callback',{@(src,event)setpos3(obj,src,event)});
end
end
methods(Access = private)
function setpos3(obj,src,event)
val = get(obj,'Value');
disp(val,'this value is')
end
end
end

Answers (1)

per isakson
per isakson on 22 Apr 2014
Edited: per isakson on 22 Apr 2014
There are different types of objects (, which is a bit confusing)
  • handle graphic objects
  • instances of user classes
The line, which causes the error should read
val = get(obj.menu_405,'Value');
I trust that you fix the problem with disp

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!