Error loading data into popup menu GUI

8 vues (au cours des 30 derniers jours)
Pedro Galvez
Pedro Galvez le 7 Oct 2017
Commenté : Pedro Galvez le 7 Oct 2017
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;

Réponses (1)

Niels
Niels le 7 Oct 2017
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;
  1 commentaire
Pedro Galvez
Pedro Galvez le 7 Oct 2017
Hi Niels, it is a function I have created in order to take directy the information I need.
Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by