dear all
i'm trying to create a gui taht consits in 2 listboxes. The idea is load some data in the listbox 2 based in the selection on the lisbox 1. The data consist in 1:1:10 numbers. (10=as)
For this i create a script in the listbox 1 callback, that loads a file contained in a directory, the script read this file and put the contents on the listbox 2. However i have a problem setting the habdles of listbox 2.
here is the script in the callback of listbox 1 that must display the list in listbox 2.
%LISTBOX 1:
function listbox 1_Callback(hObject, eventdata, handles)handles.output = hObject;%store the selected station name from listbox as station (input for
%terracem scripts)
contents = cellstr(get(hObject,'String')); %returns stationslist contents as cell array
station_selection=char(contents{get(hObject,'Value')}) %returns selected item from stationslist
handles.statsel=station_selection; %selection of item in listbox 1 stored
%put profile names of profiles in next listbox/ new version
station=handles.statsel;dirstations=handles.stationsdir;%maindir=handles.maindir;
cd(dirstations)cd(station)sel=(handles.statsel);load(sprintf('%s_swaths.mat',sel)); %load a file in the folder
as=nimnameprof=(1:1:as); %%%%%%%%%for instance, in this case the values of nim or as=10%%%%%%%
%%%%%here the program gives an error%%%%%%%%%%%%%%%%
set(handles.listbox2,'value', nameprof) %save data
guidata(hObject, handles);
all the script seems to work good until i set the handles for the next listbox (listbox2), where the loaded data (nameprof =1:1:10) must be displayed.
here is the error:
Reference to non-existent field'listbox2'.Error inTerracem_gui_v5b>stationslist_Callback(line 793)set(handles.listbox2,'value', nameprof)Error in gui_mainfcn (line 96) feval(varargin{:});Error in Terracem_gui_v5b (line 42) gui_mainfcn(gui_State, varargin{:});Error in@(hObject,eventdata)Terracem_gui_v5b('stationslist_Callback',hObject,eventdata,guidata(hObject))Error while evaluating uicontrol Callback
i dont know why i cannot set the callback for the listbox 2, someone have an idea to solve this……. thanks and thanx in advance
Best Answer