How to code a MATLAB SIMULINK automation from scratch