필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
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!

채택된 답변

Iain
Iain 2013년 5월 21일
Add: ImageProperties(fov,Plot) to your slider callback... obviously you'll need to supply fov and Plot.
  댓글 수: 2
Hanif
Hanif 2013년 5월 21일
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 2013년 5월 22일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by