Hi:
clc
clear
mobiledevlist
m=mobiledev;
delete(m);
clear mobiledev;
this is my code , in mobiledevlist it shows i have been connected with my device ,but i can find any object to get data from it ,
when run at "m=mobiledev",it occurs "Connection to this device already exists in the workspace."
did it occur by my device status is Connected ?
Thanks !

 채택된 답변

Hitesh
Hitesh 2025년 5월 12일

0 개 추천

Hi 政博,
I'm not sure why you're still encountering this error even after removing the "mobiledev" object from the workspace. Start a fresh MATLAB session so that there won't be any existing object of "mobiledev" in the memory.To resolve the issue, please try deleting the object at the end of your script. B
If you are creating the "mobiledev" object as follows
m=mobiledev;
then, after using the object for your subsequent operations at the end of the script, add the below command to delete the object.
delete(m);
This will help us to destroy the object and the existing connection. Then, it will not be required to reopen MATLAB session.
clear all;
Please do let me know in case the issue persist.

댓글 수: 4

政博
政博 2025년 5월 15일
Hi Hitesh,
Thank you for your answer , I used to creat object in command line which might cause the mobiledevlist show my device state is "Connected" , After reboot my PC , I add delete(m) in my script , the mobiledevlist show the state "Ready to Connect" .I can't find the reason why the object have been creat but not be show in
workspace .
Thank you for your idea , it truly help me solve the problem .
Walter Roberson
Walter Roberson 2025년 5월 15일
Could you possibly link to something that shows delete() of a mobiledev object? The primary documentation for mobiledev() does not talk about removing the object; the example scripts show using clear on the mobiledev() object, but not delete() that I can see.
政博
政博 2025년 5월 15일
편집: 政博 2025년 5월 15일
I think there might be a way to check if your device has been connected , in your mobile clinet ,the sensor panel will show something like waiting matlab to creat mobiledev object ,if it happend on your client but you can't find any object in your matlab ,I think trying reboot your PC and matlab may help you ?
Hitesh
Hitesh 2025년 5월 15일
편집: Hitesh 2025년 5월 15일
Hi Walter,
You’re correct that the documentation mentions using "clear" on the mobileDev() object. However, I suspected that calling "clear" doesn’t actually delete the object, which is why we were seeing the error: "Connection to this device already exists in the workspace." I checked the MATLAB documentation and found that the object can be deleted using the "delete" function.

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

추가 답변 (1개)

Aastha
Aastha 2025년 5월 12일

1 개 추천

According to the documentation of "mobiledev", the command
m = mobiledev
is used to create a mobiledev object "m". To get data from the object, Enable the "Logging" property of "mobiledev" object using the MATLAB command:
m.Logging = 1
This starts the transmission between the object and MATLAB.
For further queries, kindly refer to the MathWorks documentation of "mobiledev" linked below:
I hope this is helpful!

댓글 수: 1

Walter Roberson
Walter Roberson 2025년 5월 15일
Sadly, the documentation for mobiledev() does not include any information about how to remove the object.
By examining https://www.mathworks.com/help/releases/R2021a/matlabmobile/ug/sensor-data-streaming-tutorial.html or https://www.mathworks.com/help/releases/R2021a/matlabmobile/ug/use-logged-sensor-data.html we see that the way to remove the object is not delete() of the object, but is instead to "clear" the object.

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

카테고리

도움말 센터File Exchange에서 Sensor Data Collection에 대해 자세히 알아보기

제품

릴리스

R2021a

태그

질문:

2025년 5월 9일

편집:

2025년 5월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by