while closing the GUI in MATLAB 23a give following error

2 次查看(过去 30 天)
I have made gui where by pressing the pushbutton_2 grapgh is draw. to show any changes in the real time i have used the while loop in the function of pushbutton _2 and again some data is diplay in the text using the set(handle.text,'string',output); . when I interface this with the arduino uno borad, initialy it works fine, but athe time of closing or exit from GUI it through the following error.
hout how should I close or exit from GUI .
following are the error of programm.
----------------------------------------------------error-----------------------------------------------
Error using matlab.ui.control.UIControl/set
Invalid or deleted object.
Error in lidar>pushbutton2_Callback (line 435)
set(handles.disp1,'string',num2str(y1));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in lidar (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)lidar('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating DestroyedObject Callback.
  3 个评论
Walter Roberson
Walter Roberson 2023-10-31
set(handles.static_disp,'string',x);
What do you expect that line to do if you have closed the window and so deleted the graphics object?
Mahesh
Mahesh 2023-11-1
set(handles.static_disp,'string',x);
I used that command for showing the voltage reading of a A0 arduino analog chanal in a text block of gui. so when I closed my gui or exit from it, analog voltage which is showing on a text block should be also vanished.

请先登录,再进行评论。

采纳的回答

Steven Lord
Steven Lord 2023-10-31
You could wrap that set call in a try / catch block and check if the handle to the text box isvalid in the catch block. If it is not valid, you can assume that the user likely closed the GUI and simply break out of the while loop. [If the handle is still valid, something else has gone wrong. You could try to handle it yourself, perhaps by checking the message or identifier of the exception that you caught, or you could just rethrow the error.]

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by