File Exchange

image thumbnail

MATLAB Support Package for Raspberry Pi Hardware

Acquire sensor and image data from your Raspberry Pi.


Updated 20 Mar 2019

Editor's Note: Popular File 2018

This support package is currently unable to download third-party software for MATLAB R2017a and earlier versions. For details and workaround, see this Bug Report.

MATLAB R2017b and later versions are unaffected.

MATLAB® Support Package for Raspberry Pi™ Hardware enables you to communicate with a Raspberry Pi remotely from a computer running MATLAB. You can acquire data from sensors and imaging devices connected to the Raspberry Pi and process them in MATLAB. You can also communicate to other hardware through the GPIO, serial, I2C, and SPI pins.
This support package is functional for R2014a and beyond.

Comments and Ratings (89)

zhiqi wang

@Mohith Prabhu I have discovered different versions of mathworks_raspbian img files on your Github page, but the mathworks_raspbian_R18.2.3 seems to be R19.1.0 after unzipping, which probably does not support Matlab R2018. I want to use mathworks_raspbian_R18.2.3, so do I have to use Matlab R2019?

zhiqi wang

MATLAB Support Package for Raspberry Pi Hardware and Simulink Support Package for Raspberry Pi Hardware are installed. But firmware (downloaded from Github given in Hardware Setup) zipped as mathworks_raspbian_R18.2.3, seems to be R19.1.0. So as I validate this zip in Hardware Setup, this Setup breaks automatically. Could anyone give me some advice to install this .img fiile to my Rasppi.

@Jan Hrabina The installation of Support packages in MATLAB with version R2017b or later are unaffected and do not require any patch to be installed.

michael pak

Cannot install anything,
Simply get to the screen where it ask to insert and SD, i do and it cant find the SD.

What do i do?

Jan Hrabina

It was neccessary for me to use the "Bug report" solution also in case I have R2018b (copy the file from *.zip to Matlab folder).


Bill Chou



Starting from a Raspberry Pi 3 Model B running clean Raspbian Stretch image (June 2018)
- install matlab-rpi (sudo apt-get install matlab-rpi)
- enable desired busses (sudo raspi-conig)
- enable SSH (sudo raspi-config)

Running Matlab 2017a on Windows 10 x64 machine, ran into 4 problems and found 4 fixes below.

PROBLEM #1: Tools fail to build on raspi
Error using raspi.internal.updateServer (line 90)
Error executing command "make -C /opt/MATLAB/server_v17.1.1 -f Makefile". Details:

STDERR: In file included from /usr/include/string.h:630:0,
from devices.c:4:
devices.c:56:11: error: expected identifier or ‘(’ before ‘__extension__’
char *strndup(const char *s, size_t n)
FIX #1:
strndup already exists in standard c library, so comment out "#ifndef HAVE_STRNDUP ... #endif" section in 'C:\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\realtime\targets\raspi\server\devices.c'

PROBLEM #2: Fails LED configuration while getting available peripherals

Error in raspi/getLEDConfiguration (line 723)
trigger = ret{1};

Error in raspi/getAvailablePeripherals (line 980)
obj.LED.(id).Trigger = getLEDConfiguration(obj,name);

Error in raspi (line 246)

getLEDConfiguration() fails to identify the current trigger setting because the internal TCP request mechanism prematurely clips the trigger list after 250 chars.

FIX #2:
Modify EXT_LED_GetTrigger() in 'C:\ProgramData\MATLAB\SupportPackages\R2017a\toolbox\realtime\targets\raspi\server\LED.c' to read the full trigger list. I modified line 88 to read 512 chars instead of the original 250. Note you'll need to force a rebuild of the MATLAB I/O server on the Pi for the change to apply (use updateServer() from the raspi class).

PROBLEM #3: Board incorrectly identified as "Raspberry Pi Model B+"
FIX #3: The partial output of /proc/cpuinfo on my Raspberry Pi Model 3 board is:
Hardware: BCM2835
Revision: a02082

Modify getBoardName(obj) in raspi.m:
From: if isequal(hwId{1},'2709')
To: if isequal(hwId{1},'2709') || isequal(hwId{1},'2835')

PROBLEM #4: Unable to query I2C bus speed.
rpi = raspi(...) is able to detect 'i2c-1' but still gives the following warning: "Warning cannot query I2C bus speed..."

FIX #4: enableI2C(rpi) will enable the I2C bus at the default baud rate of 100,000.

During installation of this package on Matlab 2017a, I'm getting the following message during download of third party packages:
Download Error
There was a problem downloading the third-party software. To resolve this issue, contact Technical Support

Could anybody provide help on this issue?

I experienced quite funny situation with new RPi 3 B+ and R2018a.
I decided to use "customize the existing OS"
unfortunatelly I couldn't pass the SSH test:
I was sure, that SSH worked fine and after some attempts (still failed)
I came back to the R2017b and here everything went smoothly!
According to my expectations I can use now RPI Support Package in both 2017b as well as R2018b!

Astonishingly when I tried to check again SSH test connection in Hardware Setup using R2018b - I get all fine.
The conclusion is
Fortunately for me that I did not remove the "outdated" R2017 after installing R2018a!

David Flory

The instructions make setting up this package more difficult than it should be.

I was able to get the RPi 3 B+ as well as a Pi Zero W connected to Matlab over a wireless connection using the following method:
1. Don't bother with the setup wizard or with downloading the special Matlab release of Raspbian. Just download and install the latest version from

2. Enable SSH and a network connection. Write down the IP. The easiest way to do this is to physically log onto the Pi with a monitor and keyboard. Otherwise you will need to edit config files on the microSD. Instruction in how to do this is detailed elsewhere.

3. After installing this plugin, simply create a Matlab RPi object, i.e. mypi=raspi('yourPi'sIP','login name', 'password') The plugin will automatically install all necessary support files!

Hi Fernando,

Please check the link below, this info is also available in the comments a little below.


1. Lack of consumer complaints is the reason why Matlab Raspberry Pi Support Package has no basic commands after four years of release and has not been updated for over four years.
2. Small user group leads to less activities/contributions in Matlab central, while all the Matlab Central staff not required to answer questions, the community is only going to shrink.
3. Taking complaints regarding product’s own problems as a disrespectful/personal issue is the reason why Matlab is only developing from a developer’s perspective, not a consumer’s perspective.
4. Deleting people's reviews under the support package only means the team knows the reviews are true.

What do i do if i want to connect a raspberry pi zero w?

Works well, nice

my version is matlab R2016a and cannot install Raspberry pi 3 package ,,"Fatal Alert" any help please ,my gradution project stop on this point

Simon Orlob

There is a solution for setting up the raspberry pi also with the latest MATLAB versions.
Starting from a clean raspbian-stretch-lite (flashing SDcard like described by
- install matlab-rpi (sudo apt-get install matlab-rpi)
- enable desired busses (sudo raspi-conig)
- enable SSH (sudo raspi-config)
Now you can connect with MATLAB (in my case: raspberrypi('','user','password') )

You can also connect the rpi to MATLAB Online (see:
//sensors are working fine, haven't tested rpi3B+ yet

please add support for Raspberry pi 3B+
If anyone manage to use the newest Raspberry pi please help

By running the 'targetupdater' on my pi 3b+, by
- Setup hardware with Mathworks Raspian image R18.1.0): "No Network connection possible"
- customizing existing Hardware(stretch-lite works well) : "Establishing SSH connection with hardware failed"
in the last case, stretch- lite works well and no communication error, but not in mathlab... :-((
What's my mistake?

Does anyone know if this software supports raspberry pi 3b+ ?

I have trouble with the most basic... How I do function my raspberry pi with matlab???.... I folled the instructions step to step and nothing...

@Yuanqi Wang, All the MathWorks customized Raspbian img for different releases are hosted in GitHub. For 18a you can download from this url:

Yuanqi Wang

The img download link always broke at around 700Mb of the total 900Mb, no way to resume. Already tried several time before giving up. How come there isn't even a public download link? Very disappointed.

I have been trying to connect MATLAB 2017b to pi3.
After Installing all support packages and follow all steps several times, still connection fails.
1. MATLAB set the pi IP as, while the actual IP is
2. I can ping pi from cmd.
3. MATLAB can ping the corrected IP (manually). SSH connection however fails.
Any suggestion is very appreciate is.

Pradeep KS

MATLAB R2018a is out!!

Support added for Raspberry Pi Zero W board
You can now use the MATLAB® Support Package for Raspberry Pi™ Hardware with the Raspberry Pi™ Zero W board.

MATLAB Support Package for Raspberry Pi Hardware enables you to communicate with Raspberry Pi Zero W using Wi-Fi® or a micro-USB cable connection. For more information on how to communicate with Raspberry Pi Zero W, see

@Feng Fan: From 18a onward, during hardware setup, you will see "Download MathWorks Raspbian image" screen. Click on the 'Download' link in the screen to get This will download the Raspbian image from the github page :

You can also go to the above github page and download manually.

Feng Fan

The mathworks_raspbian_R18.1.0 can't be downloaded.

Pradeep KS

If you are facing Download Error while installing the MATLAB and Simulink Raspberry Pi Support package in R2018a release, follow below mentioned steps:

1. Go to folder location "C:\Users\<user id>\Downloads\MathWorks\SupportPackages" on your machine.
2. Delete all the old support package files and folders. Make sure the folder is empty.
3. Try installing Support package from Add-On Manager.


The raspi.m is in serious need for an update.
Following on Mark Goodnough's comment, I encounter similar problems using Pi3 with R2017a and the latest support package.
Browsing through the raspi.m script, I can see that most of the code is looking for the bcm2708 drivers, but my Pi3 is using bcm2835 drivers. I can see that some parts of raspi.m has been updated to check the bcm2835 drivers but not the i2c section.
Another problem is the LED configuration. getLEDConfiguration() is failing because it cannot identify the current trigger setting. The problem appears to be that the internal TCP request mechanism chops off the trigger list after 250 chars, and the actual trigger list is longer than that, and my default trigger for led0 is [mmc0] which lies beyond the 250 chars limit.


hao jun

Execution of
rpi = raspi('ip-address','username','password')
generates errors - exactly the same as described in previous post from 7 Oct 2017 by Mark Goodnough (PROBLEM #1: fails builing tools on raspi )

Error using raspi.internal.updateServer (line 90)
Error executing command "make -C /opt/MATLAB/server_v17.2.0 -f Makefile".

I couldn't connect to the pi in any way (LAN, Wireless, etc.), the pi couldn't be detecte, the test connection failed and the PWR LED wasn't solid red.
Despite all this I managed to connect to the pi using rpi = raspi('ip-address','username','password'), I found the IP Addess from my phone using the app network scanner and I used the default username and the password to connect pi and raspberry.
Hope this message helps someone in my condition.

Help required! Third party software download gets stuck at 1% progress.

Updated to Matlab 2017b on Windows 7 x64 machine
Reinstalled Raspberry Pi Support Package V using install to existing raspian system approach.
Ran into 3 problems and found 3 fixes:

PROBLEM #1: fails builing tools on raspi
obj = raspi('192.168.*.*', 'pi','********')
### Updating Raspberry Pi I/O server...
### Connecting to board...
### Connected to
### Creating server folder...
### Transferring source files...
### Building MATLAB I/O server...
Error using raspi.internal.updateServer (line 90)
Error executing command "make -C /opt/MATLAB/server_v17.2.0 -f Makefile". Details:

STDERR: In file included from /usr/include/string.h:630:0,
from devices.c:4:
devices.c:56:11: error: expected identifier or ‘(’ before ‘__extension__’
char *strndup(const char *s, size_t n)
FIX #1: Commented out "#ifndef HAVE_STRNDUP ... #endif" section in devices.h in the '/opt/MATLAB/server_v17.2.0' and did a on raspberry make in that directory.
strndup exists anyways. Didn't diagnose the real error.
PROBLEM #2: Board was mis-recognized as "Raspberry Pi Model B+"
FIX #2: The partial output of /proc/cpuinfo on my Raspberry Pi Model 3 board is:
Hardware : BCM2835
Revision : a22082

In the getBoardName(obj) function (in raspi.m), made these changes:
From: if isequal(hwId{1},'2709')
To: if isequal(hwId{1},'2709') || isequal(hwId{1},'2835')

The board is now properly recognized.
PROBLEM #3: rpi = raspi(...) now gives: "Warning cannot query I2C bus speed..." even though it
detects 'i2c-1'.
FIX #3: enableI2C(rpi) seems to enable it permanantly with 10000 bus speed.
Haven't checked with real I2C device and this issue may be related to problem #1 not
being run in the normal fashion.


It seems that the 3P.instrset is installed the 2nd time I launch installation.

I will see if it works in the next days.




Windows 10 Home install problem/
Cannot find the file containing firmware information:
This file has either been deleted or moved to a different location. Re-install the support package to get the required files.

I have no 3P.instrset in R2017a

Where is the problem ?


Please make a support package for the Raspberry Pi Zero and Zero W. Why this isn't already done is mind boggling...


I'm kinda new to matlab and raspberry but I had no problems setting this up! Everything works as espected/described.

@DomenicoPerillo Please refer to our github page :
All the steps required to customize Raspbian Jessie to be compatible with MATLAB and Simulink are documented there.

I'm new on using Raspberry Pi and this guide helped me a lot but I hoped there was a way to install MATLAB® Support Package for Raspberry Pi™ directly from stock firmware Raspian with jessie using sudo apt-get command, to avoid replacing Raspian with jessie stock Firmware and losing all apps.


Encountered an error writing the SD Card which I solved copying 3 DLLs
19.01.2017 14:31 5.634.720 mfc120u.dll
19.01.2017 13:26 660.128 msvcp120.dll
19.01.2017 14:26 963.232 msvcr120.dll
to: ProgramData\MATLAB\SupportPackages\R2017a\toolbox\realtime\targets\raspi\bin\win64
which already has sdwriter.exe in it.
Just search on your local PC for the DLLs.
R2017a + Windows 10


@ClementYap I got the same issue and i tried to change the installation directories and that didn't work either.. Can someone please help

Clement Yap

I ran into the problem while attempting to setup . The problem stated,

"Cannot find the file containing firmware information:

This file has either been deleted or moved to a different location. Re-install the support package to get the required files.". I tried re-installing and it is still not solved. And how do I connect pi-raspberry (Model 1B) to PC? Use USB? Which usb port?



How do i start mathematica from this image ? "mathematica" command does nothing -_-

Following on from the post below, I reverted back to R2016a and the generation of a new SD card image worked fine as before. So something has happened in R2017a - this probably isn't where I need to report a bug though, where should I do that? Thanks.

This worked very well until I tried to install it again today after upgrading to R2017a. Install works fine, but when I run the setup to generate the SD card image I get an error message saying that the downloaded image cannot be accessed because it's being used by another process. I've rebooted and uninstalled / re-installed the support package but still get the same error message.

Ali Alipour

Hi , i cant download this package send to mail for me. thanks a lot

Ali Alipour


I just tried to install it on Ubuntu and Matlab 2016a, but it says it cannot be installed because it requires the host platform to be either Win64 or Mac64.

Installing with the support package installer doesn't work either.

Does somebody know how to solve this problem?

The support package and the instructions on the Mathworks website are great!

However, I would like to use this for multiple Raspberry Pi devices simultaneously, in one M-file. Is this possible?

can I install this on Ubuntu 16.04 Matlab 2016b?

so, I have a working Raspberry Pi in our lab and I just want to connect it to MATLAB to get data and then process it - I DO NOT want to install new image on my Pi, is there any way.???

or is there any way for me to easily have a connection between the MATLAB on Windows PC and my Pi - both are in the same network and I have admin access to both and know the IPs

Hello, Please can you tell me if this supports raspberry pi zero?

Murat Belge

@Ashley Stewart: You do not have to disable the MATLAB server running on RPI to use "raspistill". Just make sure that you don't have any cameraboard objects in the MATLAB workspace. The MATLAB server does not grab the camera unless a cameraboard object is created. Hence, you can use raspistill even when MATLAB server is running.

How can I disable the MATLAB server on the RPi? I want to use the camera via Raspistill, but it's in use by the server on startup!

Support Package installer :
MATLAB Support Pachage for Raspberry pi Hardware cannot be intalled on this system
it requires :

Base Product :MATLAB
Host Platforms : Win32,Win64,Mac64

WHY NO LINUX ??????????

Ilya Glants

is there support for raspberry pi zero?


while installing package getting an error displaying "network connection down or check proxy setting" how to solve this error??



I cannot get a wireless internet connection while running this image. Is anybody else getting the same problem?

UP ! Howto get this package without extranet connection through locked firewall ?

Howto get this package without extranet connection through locked firewall ?

Murat Belge

@mchaaban: Simulink just needs the IP address of the board. Connect a monitor and keyboard to your Raspberry Pi and find out the IP address. Then try connecting to your board using the your board's IP address:

>> r = raspberrypi('<IP address>')


Hi, I am using the Matlab r2013b with raspberry pi 2 b; and I not able to connect to simulink with the support package. what should i do?

Thank you.

Murat Belge

@Miguel: Assuming that you really connected some I2C sensor to the i2c-1 bus, make sure that you either:

1. Not use device tree: You can turn it off using raspi-config utility
2. Use device tree: enable I2C driver (


Hi, I am using the Matlab r2014a and raspberry pi b, b + y 2 b; and I have the disadvantage that reads addresses on the i2c port and nothing is connected, waiting for your comments I leave.
Thank you.

pi@raspberrypi-b-plus ~ $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --


Murat Belge

We are in the process of updating the R2014a and R2014b support packages for Raspberry Pi 2 board. I would recommend you wait for the update.

If you want to add the required MATLAB server to your existing Raspbian image, run the following on the MATLAB command line after installing the MATLAB Support Package for Raspberry Pi hardware:

>> raspi.internal.updateServer('<IP Address>, '<username>', '<password>')

This function adds the required MATLAB server to your Raspberry Pi hardware. Substitute correct values for IP address, username and password.

You will need to restart the server every time your Raspberry Pi reboots.


Hello dear @Murat Belge, I'm using Matlab R2014a with raspberry pi 2, use your method of manually install the following:

$ sudo apt-get update
$ sudo apt-get install ibsdl1.2-dev alsa-utils espeak x11vnc guvcview i2c-tools libi2c-dev ssmtp ntpdate git-core v4l-utils cmake
$ cp /etc/ssh/sshd_config /home/pi/
$ echo -e "\\n\\n# Turn off reverse DNS lookup\\nUseDNS no\\n" >> /home/pi/
$ sudo mv /home/pi/ /etc/ssh/sshd_config

At this point reboot your board:
$ sudo shutdown -r now

The results were positive with Raspberry pi2 and Simulink, but now Querio know how I can do to have the tools of Matlab Support Hardware where serial, i2c, spi port is controlled.
Thank you very much.
Greetings from Peru.

Murat Belge

R2015a Support Package add built-in support for Raspberry Pi 2 Model B boards.

Murat Belge

@Joerg: Yes you need a server running on Raspberry Pi that talks to MATLAB. The firmware image that comes with the MATLAB Support Package for Raspberry Pi comes with this server baked into the Raspbian Linux image. There are other Linux customizations needed for the MATLAB support package to work with an existing Linux images. It is not just the server.

There is no way to re-configure an existing Raspberry Pi to work with the MATLAB support package in R2014b release. I'll recommend creating a new SD card containing the Raspbian Linux image that comes with the support package.

We are working on supporting this particular use case for a future release. However, we will only be supporting the Raspbian distribution.


Is it possible to configure existing Raspberry image to work with Matlab Support Package? Looks like there is some TCP server on port 18725 needed.

Murat Belge

Version 14.1.2 of the MATLAB Support Package for Raspberry Pi Hardware has been released. The updated support package contains full support for the new Raspberry Pi Model B+ board.


MATLAB Release Compatibility
Created with R2014a
Compatible with R2014a to R2019a
Platform Compatibility
Windows macOS Linux
More Files in the  MATLAB Maker Community

Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Learn About Live Editor