Since January 2010 there are 2 basic ways to interact with the Arduino board using MATLAB and Simulink:

MATLAB Interface for Arduino


You can download the code for free here : http://www.mathworks.com/academia/arduino-software/arduino-matlab.html

This lets you control your Arduino board over USB from a MATLAB session, in either Windows, Mac or Linux. For example you can instantiate an Arduino object from MATLAB using:

>> a=arduino('COM5');

and then do stuff like:

>> av=a.analogRead(5);

>> a.pinMode(13,'output');
>> a.digitalWrite(13,1);

>> delete(a)

or if you have a ladyada motor shield:

>> a.servoAttach(1);
>> a.servoWrite(1,45);

>> a.motorSpeed(4,200);
>> a.motorRun(4,'forward');

>> a.stepperSpeed(1,10);
>> a.stepperStep(1,'forward','double',100);

You can also download these slides: http://www.mathworks.com/matlabcentral/fileexchange/27843 or look at this video to learn more: http://www.mathworks.com/company/events/webinars/wbnr43537.html

Plotting Logged Arduino Data


It's often convenient to log data from the serial port of an Arduino when debugging and when using the Arduino as a base for various sensors. Commonly these include temperature and humidity, but could also include things like light, motion, or sound. Once this data is logged we most likely want to process it for the development of control logic or just general interest. Matlab and it's free alternative FreeMat provide a great solution for loading, extracting and analysing data from logged text files.

This great FreeMat and Malab tutorial provides a basis for loading a text file, scanning through it identifying the data your interested in and then plotting it for analysis.

Arduino Target for Simulink


This lets you use Simulink to create programs that run directly on the Arduino board. You can download the code for free here : http://www.mathworks.com/academia/arduino-software/arduino-simulink.html

The target (available for Windows only) allows a Simulink model (and possibly also Embedded Matlab Code) to be automatically converted to C/C++ code, compiled and downloaded to the Arduino. This is especially useful for control application that need to run at high sampling rate, and in cases where you don't want the Arduino to be connected to a host computer.

Share