Listbox et probleme de cell array
Bonjour,
je me fais la main avec l'outil GUIDE.
J'ai cree une listbox. La fonction createFlist2() definit les champs que je souhaite afficher dans la liste. Elle est appelee dans la fonction listbox1_CreateFcn(hObject, eventdata, handles).
Code:
1 2 3 4 5 6 7
| function createFlist2()
% Create the list
liste = [2005 2006 2007 2008];
% Associate the listbox with a handle
handle = findobj(gcbf,'tag','listbox1');
% Link the handle with the list
set(handle,'string',liste); |
J'utilise les "hints" proposees pour recuperer la valeur du champ selectionne
Code:
1 2 3 4 5 6 7 8
| function listbox1_Callback(hObject, eventdata, handles)
% default comments
% Hints: contents = get(hObject,'String') returns listbox1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from listbox1
valeur = get(hObject,'Value');% returns selected item from listbox1;
texte = get(hObject,'String');%recupere TOUTES les chaines de caracteres de la liste
ch_sel = texte{valeur}; |
mais MATLAB me retourne l'erreur :
Citation:
??? Cell contents reference from a non-cell array object.
Error in ==> Test1>listbox1_Callback at 87
ch_sel = texte{valeur};
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Test1 at 42
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)Test1('listbox1_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
Avez - vous une idee de mon erreur de grand debutant. Je n'ai pas trouve de solution dans les differents Forum.
Merci d'avance.
Lepapat