Set listbox with excel content --Attempt to reference field of non-structure array
Ältere Kommentare anzeigen
I have a GUI in which a want to set the content of an Excel file in a listbox, the code used is:
[ndata, text, alldata] = xlsread(filename);
set(handles.list_register,'String',cell2str(text));
The Excel file contains only one column with a string in each cell. Once the xls file is read the variable text is a cell type. When I compiled I got:
Attempt to reference field of non-structure array.
Error in Register>list_register_CreateFcn (line 100)
set(handles.list_register,'String',fields(struct(text)));
Thanks in advance for your help,
Antworten (2)
Azzi Abdelmalek
am 15 Okt. 2013
Bearbeitet: Azzi Abdelmalek
am 15 Okt. 2013
0 Stimmen
cell2str is not a valid Matlab function, it's cellstr and the variable text is already a cell array
4 Kommentare
Manuel
am 15 Okt. 2013
Azzi Abdelmalek
am 15 Okt. 2013
But the error message correspond to another line
set(handles.list_register,'String',fields(struct(text))
what struct(text) means?
Manuel
am 15 Okt. 2013
Azzi Abdelmalek
am 15 Okt. 2013
Post the entire code for this callback
sixwwwwww
am 15 Okt. 2013
Dear Manual, I assume that "text" just has one cell then you do like this:
[ndata, text, alldata] = xlsread(filename);
set(handles.list_register,'String',text{:});
I hope it helps
6 Kommentare
sixwwwwww
am 15 Okt. 2013
Is your "text" contain any data? or is it empty? Also I agree with Azzi show us your code please
Azzi Abdelmalek
am 15 Okt. 2013
If text is a cell array
set(handles.list_register,'String',text);
is correct
Azzi Abdelmalek
am 16 Okt. 2013
Why your code is in function list_register_CreateFcn ? It should be in any callback
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!