How to create a callback from a function which changes a value in another function?

2 views (last 30 days)
Doing some Image processing, I have a slider on my figure which will change my Field of View or zoom of the images.
Function Startup
-hidden-
ImageProperties(fov,Plot)
-hidden-
FOV = 30; %Field of view
%% FOV Slider
uicontrol('Style','slider',...
'Min',40,'Max',80,'Value',50,...
'SliderStep',[1 10]/40,... %Slider Increases in Increments of one
'Position', [500 875 100 20],...
'Callback',{@Slider});
- hidden -
end
function Slider(hObj,event)
fov = get(hObj,'Value');
end
function ImageProperties(fov,Plot)
-hidden-
set(Plot,'xlim'[-fov fov]
end
end
Basically I wsnt the slider to change the value of FOV and update all my images with the new FOV set by the slider.
ps Sorry for all the hidden code hope people can still help!

Accepted Answer

Iain
Iain on 21 May 2013
Add: ImageProperties(fov,Plot) to your slider callback... obviously you'll need to supply fov and Plot.
  2 Comments
Hanif
Hanif on 21 May 2013
lain thanks but it didn't work! Maybe I am doing something wrong.
uicontrol('Style','slider',...
'Min',40,'Max',80,'Value',50,...
'SliderStep',[1 10]/40,... %Slider Increases in Increments of one
'Position', [1010 765 20 120],...
'Callback',{@Slider,ImageProperties(fov,Plot)});
FOV is pre-defined above in the start up function so is Plot.
Jan
Jan on 22 May 2013
I assume, lain meant the code of the callback. The value of fov is updated in the slider's callback, but then the callback returns and the value of fov is not used anywhere. So either use it directly from inside the sliders callback, or store the fov value e.g. by GUIDATA, such that the ImageProperties function can obtain it afterwards.

Sign in to comment.

More Answers (0)

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!