Can someone help me in connecting Matlab with Android Studio and Mysql?

조회 수: 7(최근 30일)
alberto madaschi
alberto madaschi 2021년 7월 1일
편집: Sutanu Maiti 2021년 8월 5일
Hi, i need to connect an application that I've created in Android Studio with a code on Matlab. Basically, the user writes some values in the Android application that need to be given in input to the Matlab code, then this code receives the input and gives as output a value that should be displayed on the Android application. I'm using also a Mysql database (on the same pc where i have the codes with Matlab) to store values and to store the different users (every user has a customized code to be used) and I've already made the connection between this one and the Android application. By the way, I can't implement the Matlab code on the Android application, because this code it's customized according to the user that is using the App, so it would be useless to change everytime the application, instead it's better to do this on the main pc. So, i was thinking about making a connection between them using the server.
Making a recap: i would like to send values from Android Studio to a database in MySql, then to send these exact values to the code in Matlab (the code to be used need to be chosen accordingly to the user, in fact there's a table that connect the users with their ID code (the user gives this value in the app) and the specific Matlab code that needs to be used). Then, the results of the code should be sent to the MySql database and then be displayed on the application of the user.
Thank you in advance.
  댓글 수: 1
Mohammad Sami
Mohammad Sami 2021년 7월 2일
I would suggest you do not directly interface to mysql. You can use a full web development stack for example Apache + PHP + MySQL. You can write your REST API in PHP. then both Matlab and Android App will call this REST API to read / write the values.
You can also use any other web development stack you are familiar with to write your REST API.

댓글을 달려면 로그인하십시오.


Sutanu Maiti
Sutanu Maiti 2021년 8월 5일
편집: Sutanu Maiti 2021년 8월 5일
You can use Simulink support package for Android Devices to implement the logic along with user input and displaying out in a Simulink model. And then that model can be deployed as a stand alone executable app. Android support package generates, code that can be imported into android studio and then you may add MySql to it. Please follow below example to Import Project to Google Android Studio.
Follow Accept Input from Android Keyboard example to take user input from phone screen.
You can also deploy MATLAB function. PLease follow Detect Boundaries of Objects Within Video Using MATLAB Function Block on Android Device example to do so.
Enhanced Color Replacement with Customized Code example explains how to use FromApp and ToApp blocks to integrate custom Java method in Activity with generated C code.
Hope this helps..




Community Treasure Hunt

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

Start Hunting!

Translated by