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