Can you use matlab code within an Arduino sketch?

4 views (last 30 days)
Hello all,
Basically I wanna know if this is possible before moving forward. I want to create a tune within matlab that uses different frequiences and then use that tune and upload it to arduino and have that be called upon in the sketch. This tune would be for a piezo, and I would like to play a short tune a certain point within the sketch. Would this possibly or can you not upload a matlab sketch to arduino?

Answers (1)

Walter Roberson
Walter Roberson on 13 Apr 2021
MATLAB code cannot be included in an arduino sketch.
With current releases, you can target MATLAB code to be deployed to Raspberry Pi, which essentially generates C (or C++) and compiles it to send to the Raspberry.
There is currently no equivalent support for Arduino.
You can use MATLAB Coder to generate C or C++ code for a subset of MATLAB, and put that together with the appropriate hooks to send to Arduino. However, this would be "generic" target; MATLAB Coder does not know anything specific about Arduino, so you lose a bunch of the hardware support.
If you embed the MATLAB Code within a Simulink MATLAB Function Block then you can create a Simulink project that you deploy to Arduino; Simulink has Arduino support, with Arduino-specific blocks.

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!