Cannot get to work a callback function in a simple uicontrol!!!!
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (1)
Giorgos Papakonstantinou
il 30 Mag 2013
Modificato: Giorgos Papakonstantinou
il 30 Mag 2013
0 voti
Categorie
Scopri di più su Interactive Control and Callbacks in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!