Set listbox with excel content --Attempt to reference field of non-structure array

조회 수: 1 (최근 30일)
Manuel
Manuel 2013년 10월 15일
댓글: Manuel 2013년 10월 16일
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,

답변 (2개)

Azzi Abdelmalek
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
Manuel
Manuel 2013년 10월 15일
Sorry again I copied an old error, the erros is:
Attempt to reference field of non-structure array.
Error in Register>list_register_CreateFcn (line 100)
set(handles.list_register,'String',text);

댓글을 달려면 로그인하십시오.


sixwwwwww
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
Azzi Abdelmalek 2013년 10월 16일
Why your code is in function list_register_CreateFcn ? It should be in any callback
Manuel
Manuel 2013년 10월 16일
편집: Manuel 2013년 10월 17일
There is a button which opens a new GUI called Register, and when this Register is called then the listbox inside this Register needs to be created with text as content.
@Azzi Abdelmalek if you Need more data let me know.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by