Need help to delete a variable in matlab

I have created a Matlab GUI with 2 buttons, connect and disconnect, which connect and disconnects a arduino, but i have an error with my disconnect button, this is my code:
function disconnect_Callback(hObject, eventdata, handles)
% hObject handle to disconnect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete(handles.a);
msgbox('Arduino successfully Disonnected','Disconnected');
Whenever I press the disconnect button, i get the following error: "Cannot access method 'delete' in class 'arduino'."
Please help

댓글 수: 3

Jan
Jan 2018년 12월 12일
What is the contents of handles.a?
the arduino port
handles.a=arduino(port);
And does this work:
a = arduino(port);
pause(1);
delete(a)

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2018년 12월 12일

0 개 추천

Maybe try
rmfield(handles, 'a');
If that doesn't work, then I would not recommend attaching the arduino object to the handles structure. I'd just keep it separate. In fact, I'd recommend this anyway.

댓글 수: 1

thanks, but didn't work, now when i press the button it appear that the Com port is deleted, but its not.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB Support Package for Arduino Hardware에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2018년 12월 12일

댓글:

2018년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by