Filter löschen
Filter löschen

while closing the GUI in MATLAB 23a give following error

2 Ansichten (letzte 30 Tage)
Mahesh
Mahesh am 31 Okt. 2023
Kommentiert: Mahesh am 1 Nov. 2023
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 Kommentare
Walter Roberson
Walter Roberson am 31 Okt. 2023
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 am 1 Nov. 2023
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 31 Okt. 2023
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.]

Weitere Antworten (0)

Kategorien

Mehr zu Arduino Hardware finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by