Matlab on a PC

We are using Matlab on a PC and would like to stream in the  Accelerometer/Gyro data through a serial data stream directly into Matlab. How can this be done? Do you have a tutorial? 




 

Comments

  • Matlab only supports the Bluetooth SPP Profile so no, it can't be done.  You can either use the MetaWear app to save data onto your mobile device and send them to your Matlab pc or use the APIs to build an app that pushes data to the cloud / remote server that is then synced with the Matlab pc.
  • Thank you Eric. We're looking for streaming directly to PC. Is there any kind of off the shelf USB adaptor for a PC (Windows 10) that can then enable Matlab to read the data stream directly.     
  • This isn't an adapter issue.  MatLab does not support the Bluetooth LE protocol so it cannot directly communicate with the MetaWear.  You'll have to build your own Universal Windows app with the C++ API if you want to stream to the PC.

    https://mbientlab.com/tutorial/uwp/cs/
  • Would this resolve the problem:

    https://www.adafruit.com/product/2267

    I'd also like to stream real-time accelerometer and gyroscope data into Matlab. I'm happy to convert C++ files using a mexfunction, but wouldn't want to do much further development than that.

    I think this is potentially a big market in movement science / research, and an off-the-shelf solution would make you very popular!

  • I have no idea.  If MatLab supports supports either of those modes, UART or CMD, then I don't see why not.

    Barely anyone has reached out to us regarding MatLab.  An overwhelming majority of emails and forums posts we receive are about mobile development with a few Linux users sprinkled in the mix.
  • You are cutting yourself off from a huge potential audience in not having a direct simple real-time interface to Matlab, ie engineering students. Sure there are some able to use C++/C#/Android but Matlab is the MS Word of engineering. The more students you have playing with your sensors the better (for you). Whether you like it or not, it's very widely used. I know Matlab doesn't directly support BLE (yet?) so it would require something a bit clever ?

    The main reason why you don't get more people asking for it is probably because you google it and the first thing that comes up is this very thread that says you can't do it !
  • MetaBase and MetaHub export recorded sensor data as CSV files which can be imported into Matlab using the csvread function.  Sure it is not a direct interface but there isn't much that can be done until Matlab adds Bluetooth LE support, which, according to this post, is still not available in R2016b.
  • I think I understand what the Adafruit BlueFruit LE Friend above does to potentially solve the problem of communications between Matlab and Metawear. However in order for us to attempt to get Matlab to send it serial strings to then send to Metawear devices as BLE to control the devices, one would need to know the command strings for the devices, correct ?
    Is there such a command syntax list document available (rather than having to try to dig command strings out of the C++ API source code) ?

  • Take a look at the unit tests for the C++ API or the Android v3.0 beta API.
  • Thanks. But I had already looked at that device test code. Difficult to efficiently dig out what the test routines are doing and why, in a way that can be transferred to another language. They were presumably written from a command syntax master reference document ? Did I miss that document somewhere in there with the source ? The other IMU sensors we have worked with have such a master syntax document (eg  Yost).
  • The command format is not explicitly documented.  Support for other languages is done by either building on top of the C++ API or looking at the API code and unit tests, as done by the authors of the NodeJS API.

    What features do you need support for your Matlab use case and what board are you using?
  • Using the Metamotion R. We need to setup the sensor and stream sensor fusion data (Quaternion or Euler angles) in real-time as a starting point.

    We have much the same issue with doing development for Android with MIT's AppInventor, which at least has the advantage over Matlab of recently-added native support for BLE. But we need easy access to the command format to implement it.

    Both Matlab and AppInventor are much more readily accessible platforms for us (and many other potential users I suspect) than C++ / C# / Android SDK etc.
  • Given that you have a specific board in mind and you mentioned App Inventor, then my suggestions are as follows:
    1. Include the MetaWear Android API in the App Inventor project and simply use it directly in your project
    2. Create an Android app that uses the MetaWear API to do what you want, in your case stream quaternions, and record the values written to the command characteristic.  You can also use the unit testing framework to generate the commands as well.
    Since these previous 2 posts are starting to get off topic now, trending towards your project ideas, we should continue this discussion in a new thread.
  • Since this post is rather 'old' I was wondering if three are any ways by now to stream the data in real time in Matlab - but I think they still haven't added BLE support.

    By creating a dll from within VS using their BLE functions would it be possible to use those in Matlab afterwards using MEX Files?
  • That could work but that's simply a stab in the dark.  I have no idea if it actually will work.
This discussion has been closed.