Main Content


Add MATLAB function to Run-on-boot


addToRunOnBoot(raspPiObj,'function_name1') adds a MATLAB® function to Run-on-boot. If you add a function to Run-on-boot, the function automatically starts to run each time you restart the Raspberry Pi™ hardware.


collapse all

To add a function to Run-on-boot:

  1. Create a connection to the Raspberry Pi hardware.

    raspPiObj = raspberrypi('','pi','raspberry')
    board.EnableRunOnBoot = true
    rasPiObj = 
      raspberrypi with properties: 
                Name: 'Raspberry Pi'
       DeviceAddress: ''
            Username: 'pi'
            Password: '*********'
            BuildDir: '/home/pi'
     EnableRunOnBoot: 1
         BuildAction: 'Build, load, and run'

    For more information on creating a connection to Raspberry Pi hardware, see raspberrypi (Simulink Support Package for Raspberry Pi Hardware).

  2. Use the addToRunOnBoot function.

    If the function is successfully added, it returns the full path name of the function. Otherwise, it returns an empty cell.

    ans = 
         1×1 cell array 

Input Arguments

collapse all

The object that represents the connection to Raspberry Pi hardware.

Example: raspPiObj

The full path of the MATLAB function to be added to Run-on-boot.

Example: '/home/pi/MATLAB_ws/R2020a/L/work/raspberrypi_gettingstarted'

Data Types: char

Version History

Introduced in R2019b