I have a piece of code in which I use setappdata
and then later on I call the data using getappdata
which returns an empty matirx even though it is not empty. A segment of my simplified code is below:
function edit1_Callback(hObject, eventdata, handles)
C=str2double(get(hObject,'String'))
setappdata(hObject,'H',C)
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
N=getappdata(hObject,'H')
When I run the code I enter a value into the editbox
then push the pushbutton
, I get the following output
C =
5
N =
[]
I would like the following output
C =
5
N =
5
I should explain that I am using getappdata
and setappdata
as I want to pass data between different GUI's, and I am having the empty matrix problem when doing this. So this is a very simplified problem of my final goal. I have also read a lot of different articles and the information on this problem and commands, including the mathworks site but I am pretty lost with this problem.