MATLAB Answers

Setting popup menu strings from excel

1 ビュー (過去 30 日間)
adi kul
adi kul 2017 年 3 月 24 日
回答済み: ES 2017 年 3 月 24 日
I am reading the excel spreadsheet as follows:
function upload_Callback(hObject, eventdata, handles)
% hObject handle to upload (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
guidata(hObject, handles);
[FileName1,PathName1] = uigetfile({'*.xls';'*.txt';'*.csv';'*.*'},'Select the text file that contains the data');
if isempty(FileName1)
errordlg('No file was selected that contains the data so the calculation was aborted.');
flag = true;
return
end
S3.selected_dir_upload =fullfile(PathName1,FileName1);
handles.S3.selected_dir_upload =S3.selected_dir_upload ;
[S3.num, S3.txt]=xlsread(S3.selected_dir_upload)
set(handles.upload_file, 'String', S3.selected_dir_upload)
set(handles.upload, 'UserData', S3);
After that I have a popup menu which should populate the texts from the excel sheet. For which I am trying this:
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
S3 = get(handles.upload, 'UserData');
set(handles.popupmenu1,'String',S3.txt);
But I am not able to get the list updated once the excel is read. Please suggest!

採用された回答

ES
ES 2017 年 3 月 24 日
I think you should update the popupmenu string from upload call back itself.
This will update the data on the poupmenu once the file is uploaded.

その他の回答 (0 件)

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by