I have running matlab code. I just want to execute that code on the Raspberry Pi kit.

Please tell me the various ways of doing it.

  • 1
    What have you tried? Why didn't it work? I don't think this site is meant to be a substitute for you doing your own research. – joan May 3 '16 at 8:47

You cannot run Matlab on the Raspberry Pi. Matlab requires an x86 processor, while all current models of the Raspberry Pi use an ARM processor. They're fundamentally different, and incompatible. We go into that some on our blog.

The only way you can utilize a Raspberry Pi with Matlab that I know of is to use the RPi as a sensor device. You can read about that in their documentation.

| improve this answer | |

Please don't be despair if you can't find a MATLAB on any ARM platform.

On most Linux distributions (including ARM platforms), there are more than a handful of free and open-source Scientific Programming Language software packages, i.e. GNU Octave (similar and/or not 100% compatible to MATLAB), R Project (for Statistical Computing), Maxima (Computer Algebra System with symbolic and numerical expressions), etc. They should be available on a raspbian Linux distro as octave, r-base, and maxima packages, respectively. If you are more familiar with MATLAB, then I strongly recommend that you install GNU Octave package and give it a try. As I said before, GNU Octave is NOT 100% compatible to MATLAB. However, most MATLAB basic codes should run out of the box on GNU Octave. For a statistician, I believe R Project is more suitable. For those who are familiar with Mathematica, the maxima package may be a good substitute. If you are a hardcore C++ programmer, perhaps this SymbolicC++ may interest you.

I have octave, r-base, and maxima packages installed on my Rpi0 running on a Kali Linux. For a reference, I have a screen snapshot of their executions on a CLI as shown below.

Kali GNU/Linux Rolling
Linux kali 4.4.50+ #1 Fri Apr 20 17:13:36 CDT 2018 armv6l

The programs included with the Kali GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Kali GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
[snippet ...]
[habibie@kali:/home/local/PEOPLE/habibie 1%] ~
[habibie@kali:/home/local/PEOPLE/habibie 1%] ~
[habibie@kali:/home/local/PEOPLE/habibie 1%] ~
[habibie@kali:/home/local/PEOPLE/habibie 1%] ~ octave
octave: X11 DISPLAY environment variable not set
octave: disabling GUI features
GNU Octave, version 4.4.1
Copyright (C) 2018 John W. Eaton and others.
This is free software; see the source code for copying conditions.
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "arm-unknown-linux-gnueabi".

Additional information about Octave is available at https://www.octave.org.

Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html

Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> exit
2.610u+1.010s=15:32.02e(0.3%) TDSavg=0k+0k+0k max=36096k 1424+8io 6pf+0sw
[habibie@kali:/home/local/PEOPLE/habibie 2%] ~
[habibie@kali:/home/local/PEOPLE/habibie 2%] ~
[habibie@kali:/home/local/PEOPLE/habibie 2%] ~
[habibie@kali:/home/local/PEOPLE/habibie 2%] ~ R

R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: arm-unknown-linux-gnueabi (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> q()
Save workspace image? [y/n/c]: n
4.610u+0.430s=0:46.88e(10.7%) TDSavg=0k+0k+0k max=36108k 23008+0io 43pf+0sw
[habibie@kali:/home/local/PEOPLE/habibie 3%] ~
[habibie@kali:/home/local/PEOPLE/habibie 3%] ~
[habibie@kali:/home/local/PEOPLE/habibie 3%] ~
[habibie@kali:/home/local/PEOPLE/habibie 3%] ~ maxima

Maxima 5.41.0 http://maxima.sourceforge.net
using Lisp GNU Common Lisp (GCL) GCL 2.6.12
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) quit();
1.500u+0.450s=0:05.88e(33.1%) TDSavg=0k+0k+0k max=17952k 0+488io 0pf+0sw
[habibie@kali:/home/local/PEOPLE/habibie 4%] ~
| improve this answer | |

With the R2018b release of MATLAB, you can deploy your MATLAB code on Raspberry Pi as a standalone executable.

Refer the Run on Target Hardware for more information.

| improve this answer | |
  • Please provide information from the link, if the link dies your answer will not be very useful – Greenonline Oct 10 '18 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.