File Exchange

image thumbnail

MATLAB Support Package for Raspberry Pi Hardware

Acquire sensor and image data from your Raspberry Pi.

21 Ratings



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 (53)


Spencer Chen

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.


dgmcik (view profile)

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.

wajeeh mirza

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

Gaurav Sharma

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.


Yves (view profile)

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

I will see if it works in the next days.



Yves (view profile)


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.

Reeno Joseph

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


DJoeDt (view profile)

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?


timo (view profile)


timo (view profile)

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

Stephen Lewis

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.

Stephen Lewis

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

aruna jadhav


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?

Zaid Pirwani

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!

ahmed shamakh

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?


Rohini (view profile)

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


Miguel (view profile)


Daniel (view profile)

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 (


Miguel (view profile)

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: -- -- -- -- -- -- -- --


Miguel (view profile)

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.


Miguel (view profile)

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.


Joerg (view profile)

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.


Jack (view profile)


Updated image.

MATLAB Release
MATLAB 8.3 (R2014a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today