How to I convert MATLAB code written for EV3 Brick into MATLAB function block for Simulink?

6 vues (au cours des 30 derniers jours)
I have written a MATLAB Code to control the EV3 Brick (Using the MATLAB Support Package for Lego EV3). Now to run it, I need to convert it to a MATLAB Function block in Simulink. How do I convert the code into the MATLAB Function block format? I am unable to find the correct Input and Output for the MATLAB Fn block in Simulink. I am attaching my code for reference.
Thanks in Advance.

Réponses (1)

jeff matejka
jeff matejka le 16 Fév 2019
Modifié(e) : jeff matejka le 17 Fév 2019
You wont be able to use all of that in a Matlab Function in Simulink. Make sure you have the EV3 simulink support package installed and you will need the blocks for reading the sensors and motor outputs.
After you have the sensor input and motor output blocks with correct ports, youll be able to put a Matlab function block that takes the sensor as input and motor as output.
Forbthe code you posted, youll be able to do that with some logic blocks and constants.
if you need more help, the example Lego EV3 simulink programs are helpful.
Something like this
ultra_sim.PNG

Catégories

En savoir plus sur LEGO MINDSTORMS EV3 Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by