How to Create an Android App to Collect Accelerometer Data and Process with MATLAB Script?
Afficher commentaires plus anciens
Hi everyone,
I have a MATLAB script that processes data from a CSV file containing linear accelerometer data and generates a result. I need to develop an Android app that performs the following steps:
- Press a button to start.
- Wait for 10 seconds.
- Collect linear accelerometer data for 30 seconds and save it to a CSV file.
- Once the CSV file is created, apply the MATLAB script to the file and return specific results.
Is it possible to achieve this with any MATLAB add-ons, or is there a way to execute MATLAB scripts from Kotlin in Android Studio?
Thank you very much for your help!
1 commentaire
ALEX
le 25 Mai 2024
Réponses (1)
prabhat kumar sharma
le 4 Juin 2024
0 votes
Hi Alex,
I Understand that you want to run your signal processing heavy matlab script on button click in your Kotlin/Java android app.
Running MATLAB scripts for signal processing in Kotlin/Java Android apps isn't directly supported. Consider these workarounds:
1.Using MATLAB Compiler SDK
- Use MATLAB Compiler SDK to compile your MATLAB script into a Java library.
- Deploy this library on a web server as a part of a web application (e.g., using a framework like Spring Boot for Java).
- From your Android app, make HTTP requests to the web application, sending the CSV file as input and receiving the processed results back.
2.Port MATLAB Code to Kotlin/Java
For functions like butter, you might find equivalent libraries in Java or Kotlin, or you can implement the algorithm directly in Kotlin/Java.
Steps:
- Translate your MATLAB script to Kotlin, replicating the signal processing functionality.
- Use Android’s built-in sensors API to collect accelerometer data.
- Process the data within the app without needing to call out to MATLAB.
Pros: Fully offline solution, no need for network requests or external processing.
I hope it helps!
1 commentaire
ALEX
le 4 Juin 2024
Catégories
En savoir plus sur Setup and Configuration dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!