Set listbox with excel content --Attempt to reference field of non-structure array
1 次查看(过去 30 天)
显示 更早的评论
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,
0 个评论
回答(2 个)
Azzi Abdelmalek
2013-10-15
编辑:Azzi Abdelmalek
2013-10-15
cell2str is not a valid Matlab function, it's cellstr and the variable text is already a cell array
4 个评论
sixwwwwww
2013-10-15
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 个评论
Azzi Abdelmalek
2013-10-16
Why your code is in function list_register_CreateFcn ? It should be in any callback
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!