Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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,

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 15 de Oct. de 2013
Editada: Azzi Abdelmalek el 15 de Oct. de 2013
cell2str is not a valid Matlab function, it's cellstr and the variable text is already a cell array
  4 comentarios
Manuel
Manuel el 15 de Oct. de 2013
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);

Iniciar sesión para comentar.


sixwwwwww
sixwwwwww el 15 de Oct. de 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 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 16 de Oct. de 2013
Why your code is in function list_register_CreateFcn ? It should be in any callback
Manuel
Manuel el 16 de Oct. de 2013
Editada: Manuel el 17 de Oct. de 2013
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by