MATLAB and Simulink let you build Arduino projects using high level programming and block diagrams.

MATLAB Support Package for Arduino lets you communicate over USB to your Arduino and connected devices such as Adafruit motor shield, I2C, and SPI devices. Because MATLAB is a high level interpreted language you can see results from I/O instructions immediately without compiling. MATLAB includes built-in math, engineering, and plotting functions that you can use to analyze and visualize data from your Arduino. The intuitive language and ability to easily plot sensor data draw many Arduino users to MATLAB. Learn more about plot types available in MATLAB here:

Simulink Support Package for Arduino lets you develop algorithms that run standalone on your Arduino. For those of you not familiar with Simulink, it is a block-diagram environment for modeling dynamic systems and developing algorithms. The support package extends Simulink with blocks for configuring Arduino sensors and reading and writing data from them. After creating your Simulink model, you can simulate it, tune algorithm parameters, and download the completed algorithm for standalone execution on the device. One particularly useful (and unique) capability offered by Simulink is the ability to tune parameters live from your computer while the algorithm runs on the hardware. Learn more about this capability here:

Learn more:

You can learn more, see examples, and install the MATLAB and Simulink support packages for Arduino here:

MATLAB code example:

Instantiate an Arduino object from MATLAB using:

>> a = arduino('COM5');

Connect to and control Arduino inputs and outputs:

>> av = readVoltage(a,5);

>> writeDigitalPin(a,13,1);

>> delete(a)

Control the position of an Adafruit motor shield V2:

>> a = arduino('com5','Uno','libraries','Adafruit\MotorshieldV2');

>> shield = addon(a,'Adafruit\MotorshieldV2')

>> s = servo(shield,1);

>> writePosition(s,0.5)

>> dcm = dcmotor(shield,1);

>> start(dcm)

>> pause(4)

>> stop(dcm)

>> sm = stepper(shield,1,200,'RPM',10)

>> move(sm,10)