Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
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!

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by