MATLAB Answers

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

9 views (last 30 days)
Sukanya Kamboj
Sukanya Kamboj on 20 Jun 2018
Edited: jeff matejka on 17 Feb 2019
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.

  0 Comments

Sign in to comment.

Answers (1)

jeff matejka
jeff matejka on 16 Feb 2019
Edited: jeff matejka on 17 Feb 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

  0 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by