|
Hello, I'm new to matlab and I'm coding a GUI.
My aim is create a total of two interfaces, setting them all invisible. If button 1 is clicked, half of them are made visible. If button 2, the other half. I set up a function which created all objects and made them all invisible. I set up a button with a callback. I then set up the callback function to set many UIObjects visible. When the button is clicked, I got the error message:
??? Reference to non-existent field 'Text 1'.
It seems as though the objects are not able to be 'recognised' outside their initial function. I tried adding the line:
guidata(hObject,handles)
Which I understand 'updates' the handles structure. I then got the error message:
??? Input argument "hObject" is undefined.
Can anyone give me a clue as to what I'm doing wrong?
Here is an example of how I've coded it ...
function build_all_objects(hObject, eventdata, handles, varargin)
handles.fig = figure('units','pixels',...
'position',[220 150 750 550],...
'resize','off',...
'name','Untitled',...
'numbertitle','off',...
'color', [0.925,0.914,0.847],...
'menubar','none');
%Creates the pushbutton
handles.Button1=uicontrol('style','pushbutton',...
'position',[10 530 200 20],...
'string','Button1',...
'enable','on',...
'callback',{@Callback, handles});
function Callback(hObject, eventdata, handles)
set([handles.Button1],'visible','no')
Any help would be much appreciated.
|