This example shows you how to use Simulink® Support Package for Android Devices to run a Simulink model on an Android device.
Simulink Support Package for Android Devices enables you to create and run Simulink models on Android devices. The support package includes a library of Simulink blocks for using Android device sensors and network interfaces.
In this example, you will learn how to create and run a simple Simulink model on an Android device.
When you have completed this example, try these other examples:
If you are new to Simulink, we recommend completing the Interactive Simulink Tutorial, reading the Getting Started section of the Simulink documentation and running the Simulink Getting Started example.
Android device, configured using androidhwsetup
USB cable to connect the device to host computer
Simulink Support Package for Android Devices provides blocks that you can use to work with device sensors and network interfaces.
1. Enter slLibraryBrowser at the MATLAB® prompt. This opens the Simulink Library Browser.
2. In the Simulink Library Browser, navigate to Simulink Support Package for Android Devices.
3. Double-click the Camera block. Review the block mask, which contains a description of the block, a list of 'Resolution', a 'Refresh' button, and a 'Sample time' parameter.
In this task, you will create a simple Simulink model that observes the images captured by the device camera.
1. In MATLAB, select HOME > New > Simulink Model.
2. Drag the Camera block from Android Devices library to the model.
3. Drag the Video Display block from Android Devices library to the model.
4. Connect each output of the Camera block to the corresponding input of the Video Display block.
5. Save your model. A pre-configured model is included for your convenience.
In this task, you will configure and run your model on a Android device.
1. Connect an Android device to your computer with a USB cable.
2. If you did not enable USB debugging on the device when you installed the support package, enter androidhwsetup in the MATLAB Command Window and follow the instructions to update the device settings.
3. In the Modeling tab of the toolstrip, select Model Settings.
4. Select the Hardware Implementation pane and select Android Device from the Hardware board parameter list. Click OK.
5. In the Hardware tab of the toolstrip, click Build, Deploy & Start.
6. An app will be built, downloaded and run on your device. The app will now display the camera image on the device screen.
7. Save your model. A pre-configured model is included for your convenience.
In the Camera block mask, click Refresh to query the connected device for a list of supported resolutions.
Deploy the model with different camera resolutions by updating the Resolution parameter list in the Camera block mask.
This example introduced the workflow for creating a Simulink model, configuring the model, and then running it on an Android device. In this example you learned that:
Simulink Support Package for Android Devices provides blocks for using Android devices' built-in sensors.
You can use the Build, Deploy & Start button to run a model on Android devices.