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 tightk=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');enda=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.
Best Answer