Code covered by the MathWorks Limited License

Highlights from
Android Sensor support from MATLAB (R2013a, R2013b)

3.3 | 23 ratings Rate this file 162 Downloads (last 30 days) File Size: 1.04 MB File ID: #40876 Version: 1.7
image thumbnail

Android Sensor support from MATLAB (R2013a, R2013b)



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

For Android Sensor support in R2014a and higher releases see:
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)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (41)
17 Jun 2015 Marcin Lipczak  
10 Mar 2015 Deyan Dobromirov

Does it work let's say on

Because in the HW requirements it got only Galaxy S4

Comment only
22 Feb 2015 Syed Ali Saqib Rizvi  
22 Feb 2015 Syed Ali Saqib Rizvi  
19 Dec 2014 Giacomo Alessandroni

Great! Easy to install and work. Thank you.

15 Oct 2014 Paul C

Paul C (view profile)

I get the following message when using Capturing and mapping with GPS example :

Error using bufgeoquad
Expected input number 3, BUFLAT, to be a scalar.

Error in bufgeoquad (line 28)
validateattributes(buflat, {'double'}, ...

Error in CapturingAndMappingGPSExample (line 67)
[latlim, lonlim] = bufgeoquad(latlim, lonlim, (max(lat) - min(lat)), ...

What should I do??

Comment only
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?

Comment only
31 Aug 2014 Frank

Frank (view profile)

Neat. Works without any further ado.

28 Aug 2014 Stefan

Stefan (view profile)

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...

Comment only
22 Mar 2014 Jin

Jin (view profile)


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

Greg (view profile)

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?

Comment only
09 Feb 2014 Suraj Kamya

Working awesome.

05 Feb 2014 Rajiv

Rajiv (view profile)

26 Jan 2014 Hasan

Hasan (view profile)

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

Martin (view profile)

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.

Comment only
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?

Comment only
08 Jan 2014 MathWorks Mobile Sensor Connectivity Team

This submission will only work on R2013a and R2013b.

Comment only
08 Jan 2014 Prashnna Gyawali

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

Comment only
05 Jan 2014 Emad

Emad (view profile)

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

Comment only
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

Comment only
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.

Comment only
11 Sep 2013 Paul

Paul (view profile)

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.

Comment only
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.

Comment only
15 Aug 2013 Misha

Misha (view profile)

This submission will work ONLY on 13a.

Comment only
15 Aug 2013 hammad

hammad (view profile)

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

Comment only
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!


Comment only
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

Marc (view profile)

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?

Comment only
31 Jul 2013 1.1

Updated File

05 Aug 2013 1.2

Updated file.

20 Aug 2013 1.3

Updated File and readme.

26 Aug 2013 1.4

Updated file.

16 Sep 2013 1.5

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.

03 Oct 2014 1.6

Added link to R2014b support.

23 Oct 2014 1.7

Changed supported releases to 13a and 13b.

Contact us