Clear Filters
Clear Filters

How do I use the function "uicontrol" ?

4 views (last 30 days)
Hello. I described the following code.
function viewer
load view_data.mat;
fig1 = figure(1);
hax1 = axes('Units','pixels');
grid on;
hold on;
I want to change the "jjj" by using slider in "uicontrol". How do I describe the function of uicontrol?

Accepted Answer

Giorgos Papakonstantinou
Giorgos Papakonstantinou on 5 Mar 2015
The minimum example I can give you is:
sld = uicontrol('Style', 'slider',...
'Position', [5 5 120 20],...
'Callback', @(obj, evt) viewer(obj, evt));
Of course you have to change you function viewer.
function viewer(obj, evt)
Additionally, I would suggest to load view_data.mat outside the Callback function and provide (an) additional argument(s) to the CallBack with your x_layer1, y_layer1 , z_layer1 variables.
Finally, remove the clf command from function viewer because it will clear you current figure window and eventually erase the slider.
  1 Comment
Keisuke Kazama
Keisuke Kazama on 6 Mar 2015
Thank you for your kind explanation. I realized the objective.

Sign in to comment.

More Answers (0)


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!