Error using ==> set Invalid handle object.
4 ビュー (過去 30 日間)
古いコメントを表示
Hi to everybody. I'm writing a gui, this gui is provided with a series of edit box, to simplify the use of the gui I've disposed a pushbutton that is able to provide the loading of the required data from an external .dat file. When the user pushs for the first time the loading button the gui correctly populates the edit boxes with the loaded data from the .dat file. But a problem occurs when the user clicks one more time on the pushbutton the code gives the following error message:
Error using ==> set
Invalid handle object.
Error in ==> Automated_3D_Control_Surface_CFD_Analysis>Load_control_surface_data_Callback at 119
set(handles.Y_inner_eb,'String',DATA(1),'userdata',DATA(1));
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Automated_3D_Control_Surface_CFD_Analysis at 17
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)Automated_3D_Control_Surface_CFD_Analysis('Load_control_surface_data_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
Below I'm going to post You the callback function related to the load button that I've prepared:
function Load_control_surface_data_Callback(hObject,eventdata,handles)
if exist('Control Surface Data.dat')==0
warndlg('No Control Surface Data File to be loaded','warning');
end
if exist('Control Surface Data.dat')==2
msgbox('Control Surface Data File was found','Load Successful','help');
DATA=importdata('Control Surface Data.dat');
set(handles.Y_inner_eb,'String',DATA(1),'userdata',DATA(1));
handles.Y_inner_eb=get(handles.Y_inner_eb,'userdata');
set(handles.Y_outer_eb,'String',DATA(2),'userdata',DATA(2));
handles.Y_outer_eb=get(handles.Y_outer_eb,'userdata');
set(handles.Zh_inner_eb,'String',DATA(3),'userdata',DATA(3));
handles.Zh_inner_eb=get(handles.Zh_inner_eb,'userdata');
set(handles.Zh_outer_eb,'String',DATA(4),'userdata',DATA(4));
handles.Zh_outer_eb=get(handles.Zh_outer_eb,'userdata');
set(handles.Cf_inner_eb,'String',DATA(5),'userdata',DATA(5));
handles.Cf_inner_eb=get(handles.Cf_inner_eb,'userdata');
set(handles.Cf_outer_eb,'String',DATA(6),'userdata',DATA(6));
handles.Cf_outer_eb=get(handles.Cf_outer_eb,'userdata');
set(handles.Gap_inner_eb,'String',DATA(7),'userdata',DATA(7));
handles.Gap_inner_eb=get(handles.Gap_inner_eb,'userdata');
set(handles.Gap_outer_eb,'String',DATA(8),'userdata',DATA(8));
handles.Gap_outer_eb=get(handles.Gap_outer_eb,'userdata');
set(handles.Cb_inner_eb,'String',DATA(9),'userdata',DATA(9));
handles.Cb_inner_eb=get(handles.Cb_inner_eb,'userdata');
set(handles.Cb_outer_eb,'String',DATA(10),'userdata',DATA(10));
handles.Cb_outer_eb=get(handles.Cb_outer_eb,'userdata');
set(handles.Gap_y_inner_eb,'String',DATA(11),'userdata',DATA(11));
handles.Gap_y_inner_eb=get(handles.Gap_y_inner_eb,'userdata');
set(handles.Gap_y_outer_eb,'String',DATA(12),'userdata',DATA(12));
handles.Gap_y_outer_eb=get(handles.Gap_y_outer_eb,'userdata');
if DATA(13)==1
set(handles.Nose_shape,'SelectedObject',[handles.Round_rb]); % Round Nose Selected
handles.Nose_Shape=1;
end
if DATA(13)==2
set(handles.Nose_shape,'SelectedObject',[handles.Elliptic_rb]); % Elliptic Nose Selected
handles.Nose_Shape=2;
end
if DATA(13)==3
set(handles.Nose_shape,'SelectedObject',[handles.Medium_rb]); % Medium Nose Selected
handles.Nose_Shape=3;
end
end
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
When the users clicks twice on the load button seems like as the code loses the control of the handles variable but I can't understand why. This is not the first time that i use a loading button to populate edit boxes into a gui, but this is the first time that this error occurs to me. Any suggestion to solve this problem? Thanks!
0 件のコメント
採用された回答
Jan
2011 年 11 月 17 日
In the callback function you replace handles.Y_inner_eb with its UserData:
handles.Y_inner_eb = get(handles.Y_inner_eb, 'userdata')
If the UserData does not contain the handle itself, the value of the field Y_inner_eb is not a valid handle anymore. If the UserData do contain the handle itself, this operation is redundant.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!