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?
Vincent Valenzuela
Vincent Valenzuela 2018 年 12 月 12 日
the arduino port
handles.a=arduino(port);
Jan
Jan 2018 年 12 月 12 日
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 件のコメント

Vincent Valenzuela
Vincent Valenzuela 2018 年 12 月 13 日
thanks, but didn't work, now when i press the button it appear that the Com port is deleted, but its not.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMATLAB 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