I am programming a GUI and i want to save data in a callback function in matfile. I was under the impression, that if i use save only the functions workspace will be saved. Does hObject include all GUI objects in the function workspace?
save_pushbutton = uicontrol('Parent', tab ,'Style','pushbutton','Callback',@save_callback,... 'String','Save',... 'FontSize',8,... 'Units', 'normalized', 'Position',[.15 .05 .1 .05]); editfield = uicontrol('Parent', tab ,'Style','edit','Callback',@input_control,... 'String','',... 'FontSize',8, 'TooltipString', ['Input must be numerical'], ... 'Units', 'normalized', 'Position',[.15 .8 .1 .05]);function save_callback(hObject, eventdata) x = get(editfield,'String'); save('save.mat'); end
In this example i want to save x in the mat file. Since i have a lot of variables i tried to keep it short and not name them all individually (save(Filename,x,y…).
Edit: Apparently there is a GUI workspace and GUI/callback workspace. I only want to save the GUI/callback.
Edit: Added more code
Best Answer