Error loading data into popup menu GUI
2 次查看(过去 30 天)
显示 更早的评论
Hello,
I'm creating a GUI in which I import data from an Excel and I want the name of the columns to appear as options in a pop-up menu. The problem is that it doesn't happen and an error appear. What can I do? I think the error is in the last line but I do not know how to solve it.
Thank you very much!!! Pedro
This is my code:
function datagraphV1
f=figure('Visible','off','Position',[100,100,450,285]);
hload=uicontrol('Style', 'pushbutton',...
'String','Load .xlsx','Position',[315,220,70,25],...
'Callback',{@loadbutton_Callback});
hpopupX=uicontrol('Style','popupmenu',...
'String',{'popupmenuX'},...
'Position',[300,75,100,25],...
'Callback',{@popupX_Callback});
function loadbutton_Callback(hObject,eventdata,handles) %Function callback for loading the Excel and changing the
pop-up menu X.
handles.filename=uigetfile('*.xlsx');
guidata(hObject,handles);
[Comp, Prod, OthInfo, colnames,numcolum]=extractdataexcelV2(handles.filename);
hpopupX.String=colnames;
0 个评论
回答(1 个)
Niels
2017-10-7
Hi Pedro,
[Comp, Prod, OthInfo, colnames,numcolum]=extractdataexcelV2(handles.filename);
extractdataexcelV2
I have never seen this command before. If you want to extract data from an excel file you can use xlsread
like:
[number, text] = xlsread(filename,range); % xlsread('testfile.xlsx','A6:F32');
If text is a vector, your last line should be fine
in my example:
hpopupX.String=text;
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!