UI Control callback function problem
显示 更早的评论
I have done a small program based on show in a static text the values of the slider everytime I touch the slider. I'm working in dot notation ( e.g. no using get and set )and without using GUIDE. I don't know how to use the callback function for make it works, even I know the command that works.
Here is the program:
%%Figure Creation
fig = figure
fig.Color = 'b'
fig.Tag= 'fig1'
fig.Name= 'SliderGUI'
%%Slider Creation
slider = uicontrol('Parent',fig,'Style','Slider','Min',0,'Max',1, ...
'SliderStep',[0.01 0.10], 'Position', [100,100,300,25]);
slider.BackgroundColor = 'k'
slider.Tag = 'slider1'
slider.Callback=@sliderCallback
%%Create of UIControl Static text
static = uicontrol ('Parent',fig,'Style','text','Position', ...
[100,150,300,250], 'Value', 0 ,'String', 'Slider Value');
static.FontName = 'Arial';
static.FontSize =100;
static.BackgroundColor = 'c'
static.Tag = 'static1'
static.Callback=@staticCallback
%%Slider Callback function
% Here is where I have problems
function sliderCallback(slider,eventdata)
static.String=slider.Value
end
The command
static.String=slider.Value
Works good, but I don't know how to define the callback function. I try a lot of things but anything have worked.
Thank's for the help!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!