MATLAB Answers

0

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

Asked by Sukanya Kamboj on 20 Jun 2018
Latest activity Edited by 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.

1 Answer

Answer by jeff matejka on 16 Feb 2019
Edited by 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.