Code covered by the MathWorks Limited License

Highlights from
Android Sensor support from MATLAB


3.3 | 19 ratings Rate this file 614 Downloads (last 30 days) File Size: 1.04 MB File ID: #40876
image thumbnail

Android Sensor support from MATLAB



31 Jul 2013 (Updated )

Use MATLAB to acquire sensor data from built-in sensors on your Android device.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

This submission enables MATLAB to access onboard sensors on Android mobile devices. With this submission, you can access a mobile device’s accelerometer, magnetometer, location, orientation and compass information directly from MATLAB running on your computer. You can access current and logged sensor data, and you can use MATLAB to visualize and analyze the mobile sensor data or make decisions based on the acquired data.

To use this submission, the computer and mobile device must be on the same network. The submission includes the necessary MATLAB files and a read me document for initial setup.
In order to use this support, you must first install the “Sensor UDP” mobile app available from Google Play.

For more information about MATLAB Android sensor support:

To access iPhone or iPad sensors from MATLAB:

Required Products MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (35)
10 Sep 2014 Debejyo Chakraborty

The mobile app needs work. Hate to have to enter all the settings every time I restart the app. Don't like the "send" option. It should just echo at a user defined interval.

The .m program worked once out of the 3 attempts.

02 Sep 2014 MathWorks Internet of Things Team

Hi Deborah,

Which mobile phone and version of MATLAB are you using? Having this information might be helpful in figuring our the root cause of the erroneous behavior.

A couple of things to check:

1. Are the computer and mobile device on the same Wifi network?
2. Does the Mobile Sensor Explorer app show any data for any of the sensors?

31 Aug 2014 Frank

Neat. Works without any further ado.

28 Aug 2014 Stefan

Works out of the box!

Mobile App not very handsome.

For those who have problems:

Check your home folder and firewall!

27 Aug 2014 Deborah Apthorp

Can't get it to work at all. Tried the mobile setup first as instructed, and got the error messages as above. Finally managed to fix that, ran mobile setup successfully, but still can't get Matlab to see any data. Am getting error message: Error using CapturingAzimuthRollPitchExample (line 35)
No data received. Type "help sensorgroup" for help diagnosing the problem.
I have tried this on two separate wireless networks now (home and work). If I could get this to work it would be really awesome for my research and I would up my rating accordingly.

09 Jun 2014 Luis Cuya Caycho

Muy buena!

25 May 2014 AAA ESV

muchas gracias, muy buena programación...

22 Mar 2014 Jin


thanks for your code. I have a problem:
"No data received."

My host computer is also connected to network through WiFi, is there problem for the mobile phone to transmit the data?

08 Mar 2014 Greg

No GPS transmitted from Galaxy S II. All other sensors rcv good. GPS enabled under Location Services. Any ideas on what's preventing GPS transmission?

09 Feb 2014 Suraj Kamya

Working awesome.

05 Feb 2014 Rajiv  
26 Jan 2014 Hasan

I get these problems when I try to install it on R2013b on Wnd7 64bit. I added the folder and subfolders to the path.

Warning: Installation failed.
Error using matlab.apputil.install (line 38)
The specified file 'Mobile Sensor Explorer.mlappinstall' could not be found.

Error in setupmobile (line 37)
matlab.apputil.install('Mobile Sensor Explorer.mlappinstall');

25 Jan 2014 Martin

Works perfectly. examples have some issues, but the main functions are good. Exactly what I needed.

13 Jan 2014 MathWorks Mobile Sensor Connectivity Team

As stated in the header of The GPS example file, Mapping Toolbox (which includes geopquadpt) is required for that example to be fully functional. The other examples included in the submission do not require Mapping Toolbox.

13 Jan 2014 Juyeong

I tried to follow the example(Capturing and Mapping GPS Example) and failed to run the line

[latlim, lonlim] = geoquadpt(lat, lon);

with error message
"Undefined function 'geoquadpt' for input arguments of type 'double'."

am I missing the function 'geoquadpt' in my path? or other problems?

08 Jan 2014 MathWorks Mobile Sensor Connectivity Team

This submission will only work on R2013a and R2013b.

08 Jan 2014 Prashnna Gyawali

Isn't there any possibility of using this submission on the older version of MATLAB like R2011a??

05 Jan 2014 Emad

Same problem as "danushka bandara": when I run setupmobile on 64 bit Matlab 2013a
The specified file 'Mobile Sensor Explorer.mlappinstall' could not be

31 Dec 2013 qian yong  
17 Dec 2013 J.R.! Menzinger  
18 Nov 2013 jomi karacha

Thanks !

15 Nov 2013 danushka bandara

I get this error when I run setupmobile on 64 bit Matlab 2013a
The specified file 'Mobile Sensor Explorer.mlappinstall' could not be

23 Sep 2013 Teemu Pulkkinen

Any chance you could add an option for turning off logging? I have no need for it (I do it myself when I need to), and I dislike having to periodically empty it because it's growing so large.

11 Sep 2013 Paul

Works in France on Android HTC One X device after setting language to English. No Position/Altitude, though. Please provide a Simulink block! thanks.

05 Sep 2013 Dennis Nielsen  
29 Aug 2013 MathWorks Mobile Sensor Connectivity Team

We have identified a bug when using Android devices configured with European settings. In this scenario, MATLAB will not receive data, and the connection will time out. We are working on a fix, but as a workaround, set your device to “US English” while using the SensorUDP app.

27 Aug 2013 MathWorks Mobile Sensor Connectivity Team

The most recent update on 8/26 includes a minor change to one of the examples (azimuth, pitch, roll) included in the submission. It was changed to make the sample code more readable. If you already were using the prior version, it is not necessary to download this update.

15 Aug 2013 Misha

This submission will work ONLY on 13a.

15 Aug 2013 hammad

would this submission run only on 2013a version or may be compatible with older versions also?

09 Aug 2013 Mark Jones

Hi Marc, David, and Chethan,

Can you tell us the full path to where you have unzipped the package to? For example, where does mobilesensormlconverter.dll curently reside?

Also, just to be sure, you did run setupmobile.m first, correct?

Please let us know at:

Let's see if we can't figure out what is going on here and improve your experience!


09 Aug 2013 Chethan C U

Yup... same error here..

08 Aug 2013 DAVID Torres  
08 Aug 2013 DAVID Torres

Same problem as Marc:
Failure to load the requested plugin:

I can't add the private folder to the path.

06 Aug 2013 Marc

I've followed the instructions and received the following error:
Warning: The following error was caught while executing
'matlab.mobilesensor.internal.MobileSensorController' class destructor:
Attempt to reference field of non-structure array.
> In sensorgroup>sensorgroup.sensorgroup at 395
Failure to load the requested plugin: C:\...\private\win64\mobilesensormlconverter.dll

But the file does exist and I am in the correct directory. Any advice?

31 Jul 2013

Updated File

05 Aug 2013

Updated file.

20 Aug 2013

Updated File and readme.

26 Aug 2013

Updated file.

16 Sep 2013

Fixed problem with receiving data on Android phones with European settings. Enhanced install file(setupmobile.m) now checks for supported MATLAB versions. Minor documentation updates.

Contact us