Hello everybody.
I am new user of GUi and have a maybe stupid question. I have a main program from which I call a gui created with guide. From this Gui function (called button_ter), I would like to retrieve de data of one of the callback to use it in the main program. Here is the part written in the gui (with guide) from which I would like to extract the "lambda" value:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
uicontrol(hObject) uiresume; close(handles.figure1) %delete(hObject.figure1);
function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)handles.lambda = str2double(get(hObject,'String'))varargout{2}=handles.lambdaguidata(hObject,handles)%handles = guidata(handles.lambda);
setappdata(handles.edit1,'lambda',varargout{2})
I tried to retrieve the data from the main program with "getappdata" in this main program but it doesn't work. After looking a lot on matlab help,I've tried many things… test=getappdata(@edit1,lambda) test=getappdata(@button_ter,lambda) test=getappdata(@button_ter,edit1)
but none worked. What I do not understand is that the data seems to be correctly generated in my gui code because I see this on the prompt:
handles = figure1: 173.0016 edit1: 4.0017 text3: 3.0017 text2: 2.0017 pushbutton1: 1.0017 uitable1: 0.0017 text1: 174.0016 output: 173.0016 lambda: 45
varargout =
[] [45]
but after that, either it writes -Undefined function or variable -or Conversion to double from function_handle is not possible.
I'm sure I forgot something stupid in the command line from my main program.
But What? Does anyone have an idea for me?
Thanks a lot.
Scilla
Best Answer