MATLAB: Populating drop down gui from file

callbackguiimporting excel data

I created a Load Button which loads the excel file then I want to populate a pop up menu from column E of this file. How can I do that? Currently this give me an error
hload = uicontrol(f,'Style','pushbutton','String','Load Data',...
'Position',[380,260,70,25],...
'Callback',{@loadbutton_Callback});
hsubject = uicontrol(f,'Style','popupmenu',...
'String',{'Injury Level'},...
'Position',[5,260,100,25],...
'Callback',{@subjectpopup_menu_Callback});
%Each callback prompts user to select file to load and display.
function loadbutton_Callback(hObject, eventdata, handles)
disp('Hello 1');
[file] = uigetfile('.xlsx');
disp(file);
[num,txt,raw] = xlsread(file,'E2:E9');
disp(txt);
set(handles.Injury,'String',txt);
guidata(txt,handles.hsubject); %save data to gui
updateTable(txt); %update Table
end

Best Answer

It looks like you're using GUIDE because I see this line:
function loadbutton_Callback(hObject, eventdata, handles)
Yet I also see that somewhere/somehow you're "manually" creating controls using the uicontrol() function. Why are you doing that? Why not just place the things on the GUI using GUIDE? Like the popup menu and the pushbutton??? Assuming you do that, you can simply do
columnE = raw(:, 5);
handles.uitable1.Data = columnE;
or, if you have an antique version of MATLAB, you use the old set() notation:
set(handles.uitable1, 'Data', columnE);
Related Question