Android app and Matlab socket communication

1 view (last 30 days)
I want to send the accelerometer data from my android phone to matlab to plot graph. I know about matlab app but i want to create my own app which does the same.Can anyone provide the code required for accepting the data into matlab.

Answers (1)

Cam Salzberger
Cam Salzberger on 4 Aug 2017
Hello Sumit,
Though I don't have code for you, here is an idea for how you could go about doing this. The problem primarily seems to be in two parts: (1) Reading and sending the data from MATLAB, and (2) Receiving and displaying the data on your computer.
1) You have a few options here, so I'll just mention a couple:
a) If you have Simulink and Embedded Coder, you can use the Simulink Support Package for Android to create your own apps from Simulink models. You can use the Accelerometer block to read the data from your sensors, and the UDP Send block to broadcast the data over the network. You could even put a scope or six into the model, and view the data directly on your phone.
You'll need your phone to be on the same WiFi network as your computer for the UDP communication to work though.
b) There are various apps on the Play Store that you can get to broadcast your sensor data over a network. Here is one example. No need to make your own app.
2) There are also a couple of ways to get the data into MATLAB, depending on what products you have:
a) Instrument Control Toolbox udp function.
b) DSP System Toolbox dsp.UDPReceiver class.
c) Some other third-party code or tool. Here's one example from the File Exchange.
Once you have the data in, you can display it however you like. Hope this helps!
-Cam

Community Treasure Hunt

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

Start Hunting!