Getting Started with Android™ Devices
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
Task 1 - Review Android Block Library
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.
Task 2 - Create a Model for Android Devices
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.
Task 3 - Configure and Run the Model on Android Devices
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 your Simulink model, click Simulation > Model Configuration Parameters to open Configuration Parameters dialog.
4. Select the Hardware Implementation pane and select Android Device from the Hardware board parameter list. Click OK.
5. In your Simulink model, click the Deploy to Hardware button on the toolbar.
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.
Other Things to Try
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 Deploy to Hardware button to run a model on Android devices.