Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Iain
Iain il 21 Mag 2013
Add: ImageProperties(fov,Plot) to your slider callback... obviously you'll need to supply fov and Plot.
  2 Commenti
Hanif
Hanif il 21 Mag 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 il 22 Mag 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by