MATLAB Answers

"index exceeds matrix dimensions" when I connect my Raspberry Pi model B to Matlab2013b.

2 views (last 30 days)
Aditya G Manjunath
Aditya G Manjunath on 24 Aug 2014
Could please someone help me with this error?


Aniruddha Phatak
Aniruddha Phatak on 24 Aug 2014
Please provide some additional details. 'Index exceeds matrix dimensions' is an error that occurs when the indices of a matrix reference a value that is more than the actual number of elements in the row or column of a matrix. e.g. a=[1 1]; a(3)=0;
Bob Clark
Bob Clark on 7 Nov 2014
I get a similar issue trying to install the Simulink-to-RaspPi (a prerequisite it seems for the Matlab-to-RaspPi package). I'm at the 'Connect the Raspberry Pi hardware' step, everything's plugged in and my RaspPi B is up, and rebooted to the desired host name. I hit 'next' and I get 'Error: Connect the Raspberry pi hardware' window that just says 'In an assignment A(:) = B, the number of elements in A and B must be the same.' Normally it gives a code line reference, but this one doesn't, as if its running a compiled mex function.
I'm running in Matlab 2014a.
Anybody seen that before? I've tried running through all the steps repeatedly. Would it have to do with having 2 Raspberry Pi's on the network at once? I unplugged the other one, repeated all the steps, and I still get the same 'helpful' error message. What am I missing?
Could it have to do with my Apple Time Machine routers? RaspPi wakes up with a weird IP address, like Should I manually force it to something similar to my PC to get it on the same subnet?
Are there things I can be doing on the RaspPi terminal that would help? The Matlab command window just sits idle, no debug info there either.
I'm stumped. Anybody?

Sign in to comment.

Answers (1)

Murat Belge
Murat Belge on 10 Dec 2014
You can install MATLAB Support Package for Raspberry Pi without the Simulink Support package. Just uncheck Simulink support package in the installer GUI.
What network configuration did you choose when connecting your Raspberry Pi to the network (in the "Configure network" window)?
Work-around: If you created the SD card for the Raspberry Pi, just skip the "Connect the Raspberry Pi Hardware" GUI by clicking "Cancel" button. Then on the MATLAB command line execute:
>> raspi.internal.discoverIpAddress
ans =
Hostname: 'raspberrypi-RqgddnxxMD'
IpAddress: ''
The command above should display the IP address of your Raspberry Pi. Using this IP address, execute the following:
>> rpi = raspi('<IP address of your Raspberry Pi>')
Once you can establish the connection, you should be able to run Simulink or MATLAB examples for Raspberry Pi.


Eric Bott
Eric Bott on 29 Apr 2015
I have the same problem. I have tried both 2014a and 2015a. I am trying to install on a machine on a company network so as to enable Simulink code generation to the pi target via company network. The workaround above did not work for me. I need it to run in Simulink. If cancel is selected then the Simulink raspberry pi support package appears not installed, and none of the options for running the raspberry pi target become visible. At his point, no capability for interacting with the connected pi appears to be possible. I have installed successfully many times on other machines not connected to company network without issues.
Eric Bott
Eric Bott on 29 Apr 2015
Further experimentation reveals that it is only when the pi is found on the network that this error appears. If the pi is disconnected from the network, then the Raspberry Pi detection process times out without event.

Sign in to comment.

Translated by