Go Down

Topic: Arduino to MATLAB (Read 10225 times) previous topic - next topic


I know it's been a while since the last post on this topic, but I did find a solution which actually did work! Lowell Toms posted a great example on the Matlab File Exchange including two examples both the Arduino sketch and Matlab script. Ran on Mac OSX 1.5.8 with R2010a, and Arduino 0018.

Hope that helps!



UPDATE: There are now 2 standard ways to interact with the Arduino From MATLAB and Simulink:

MATLAB Interface for Arduino
You can download the code for free here :

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:
or look at this video to learn more:

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 :

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.

Go Up