In Matlab's GUIDE, I am trying to dynamically change a popup menu's text with the header of a data file when that file is first selected using the choose_data_button. However, it gives me the error that the group_variable_popupmenu is a non-existent field.
This post might have the answer to my question, but I don't understand what's going on: MATLAB GUI error Reference to non-existent field '---'
% --- Executes on button press in choose_data_button.
function choose_data_button_Callback(hObject, eventdata, handles)
% hObject handle to choose_data_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile( ... );
set(handles.patient_data_file, 'string', fullfile(pathname,filename));
data = csvimport(fullfile(pathname, filename));
%%%%% ERROR (Reference to non-existent field 'group_variable_popupmenu'.):
set(handles.group_variable_popupmenu, 'string', data(1,:));
% --- Executes on selection change in group_variable_popupmenu.
function group_variable_popupmenu_Callback(hObject, eventdata, handles)
% hObject handle to group_variable_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function group_variable_popupmenu_CreateFcn(hObject, eventdata, handles)
% hObject handle to group_variable_popupmenu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
Would using GUIDATA instead of get/set be a better option? New to GUIDE and Matlab, so any explanation would be extremely helpful.
Edit--Full error message:
Reference to non-existent field 'group_variable_popupmenu'.
Error in mockup>choose_data_button_Callback (line 148)
set(handles.group_variable_popupmenu, 'string', data(1,:));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in mockup (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)mockup('choose_data_button_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
handlesand see ifgroup_variable_popupmenuis one of them. - excaza