How can I modify and then store a value in editable box using guidata. In the future I will be need to retrieve that value in other GUI and maybe modify it also. I get the next error when executing for the second time a callback.
Error using handle.handle/getInvalid or deleted object.Error in Initial_parameters>button_1_callback (line 63)i_p.Vpol=str2double(get(i_p.Vpol,'string'));Error while evaluating UIControl Callback
The main function's code and the callback's function are the following:
function i_p = Initial_parameters(hObject,eventdata)%Initial_parameters is a function in which you can store
%the velocity and density of the air
%
%Creation of the figure
fig = figure('units','pixels',... 'position',[50 500 400 100],... 'menubar','none',... 'name','Расчет АХ самолетов - Исходные данные',... 'numbertitle','off',... 'resize','off');i_p = guihandles(fig);%guidata(i_p.fig,i_p);
%Components
i_p.text1 = uicontrol('style','text',... 'units','normalized',... 'position',[0.05 0.6833 0.255 0.2666],... %'min',0,'max',2,... % This is the key to multiline edits. 'string','Скорость полета');i_p.Vpol = uicontrol('style','edit',... 'units','normalized',... 'position',[0.355 0.6833 0.595 0.2666],... %'min',0,'max',2,... % This is the key to multiline edits. 'string','225',... 'tag','flight velocity');i_p.text2 = uicontrol('style','text',... 'units','normalized',... 'position',[0.05 0.3666 0.255 0.2666],... %'min',0,'max',2,... % This is the key to multiline edits. 'string','Плотность воздуха');i_p.plotn = uicontrol('style','edit',... 'units','normalized',... 'position',[0.355 0.3666 0.595 0.2666],... %'min',0,'max',2,... % This is the key to multiline edits. 'string','1.225',... 'tag','air density');i_p.pushbutton_1 = uicontrol('style','push',... 'units','normalized',... 'position',[0.05 0.05 0.425 0.2666],... 'HorizontalAlign','left',... 'string','Сохранить',... 'callback',@button_1_callback);i_p.pushbutton_2 = uicontrol('style','push',... 'units','normalized',... 'position',[0.525 0.05 0.425 0.2666],... 'HorizontalAlign','left',... 'string','Назад',... 'callback','close all;Main_menu');%display([i_p.Vpol i_p.plotn]);
uicontrol(i_p.Vpol) % Give the editbox control.
guidata(fig,i_p);end%---------------------------------------
%Save the values
function button_1_callback(hObject,eventdata)%button_1_callback is a function that change the value
%stored in Vpol and plotn
% Error using handle.handle/get
% Invalid or deleted object.
%
% Error in Initial_parameters>button_1_callback (line 58)
% i_p.Vpol=str2double(get(i_p.Vpol,'string'));
%% Error while evaluating UIControl Callback
%i_p=guidata(hObject);i_p.Vpol=str2double(get(i_p.Vpol,'string'));i_p.plotn=str2double(get(i_p.plotn,'string'));display([i_p.Vpol i_p.plotn]);guidata(hObject,i_p); end
Best Answer