Main Content


Add MATLAB function to Run-on-boot

Since R2019b

Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.


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).

  2. Use the addToRunOnBoot function.

    If the function is successfully added, it returns 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