How can I use the ToApp/FromApp-function from Simulink?

1 次查看(过去 30 天)
Hello everybody!
I work on a project to control a motor via an app on android. Therefore I have already written an app in java to use an IOIO-Board to control the motor manually. Furthermore I want to use Simulink to read-out the acceleration sensor of the smartphone and convert this data into distance. So I can reach a specific position later. So far so good.
My problem is that I do not know how to use the ToApp-function from Simulink to send the data from a Simulink-app to my existing app. I do not know how to write the function in java to gather this data and the help in Simulink is not very helpful to me.
I use the Samsung Galaxy S5/Google Nexus 5 with Android 4.4.2/5.0, an IOIO-Board and MATLAB R2014a/Simulink and the Simulink support package for Samsung Galaxy Android Devices.
I hope someone can help me with my question.
Best regards, Max

回答(1 个)

Subin Kuttappan Stellal Mary
编辑:Subin Kuttappan Stellal Mary 2016-5-4
Refer this link :
As a starting point, use the following code to get the data to Java code. Note that 'FilteredData' is the method name I have given in the ToApp block parameters :
public void FilteredData (float[]a) {
for(int i=0;i<a.length;i++){
Log.d("SensorData",i+":"+a[i]);
}
}

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by