Consider the following easy example:
function GUI_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to GUI (see VARARGIN)
% Choose default command line output for GUI
handles.output = hObject;clchandles.ColVec = []pushbutton4_Callback(hObject, eventdata, handles)% calling Button4 here
% Update handles structure
guidata(hObject, handles);
and the following callback function for Button4,
function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)handles.ColVec = [1 .1 .1];guidata(hObject,handles)
Naturally when the GUI runs for the very first time, the ColVec should be equal to [1 .1 .1], while it shows empty! handles.ColVec however is equal to [1 .1 .1] when I manually press the Button4! Does somebody know why the handles value cannot be automatically changed when the Button4 is called back in OpeningFcn? and what's the workaround of it to get the ColVec = [1 .1 .1] without manually pressing Button4?
Thanks
Best Answer