You can use the functions in Read and Write Data in a MATLAB Function block with the Simulink® Support Package for Arduino® Hardware to generate code that can be deployed on Arduino Hardware.
Deploy Arduino Functions to Arduino Hardware Using MATLAB Function Block
Code generation of MATLAB Arduino functions in a MATLAB Function block.