Cannot get to work a callback function in a simple uicontrol!!!!
古いコメントを表示
I have created this simple function:
function b=hide(a)
% a is gcf
hObj=uicontrol(a,'Style', 'slider',...
'Min',1,'Max',2,'Value',2,...
'Position', [400 20 120 20],'Callback',@test);
axis tight
k=get(hObj,'Value');
b=test(k);
function [a]=test(val)
% val=get(hObj,'Value');
if val==1
set(findobj('Tag','plota'),'visible','on');
set(findobj('Tag','plotb'),'visible','off');
elseif val==2
set(findobj('Tag','plota'),'visible','off');
set(findobj('Tag','plotb'),'visible','on');
else
set(findobj('Tag','plota'),'visible','on');
set(findobj('Tag','plotb'),'visible','on');
end
a=val;
I want to hide or reveal two plots according to the value of the slider and also receive the value of the slider but I get an error:
Error while evaluating uicontrol Callback
when I call the hide(gcf) from another m file.
採用された回答
その他の回答 (1 件)
Giorgos Papakonstantinou
2013 年 5 月 30 日
編集済み: Giorgos Papakonstantinou
2013 年 5 月 30 日
0 投票
カテゴリ
ヘルプ センター および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!