Starting with MATLAB R2019b, Simulink has greatly simplified building, downloading, connecting, starting, stopping, and disconnecting of real-time code with external mode operation.
To build, download, connect, and start the model for real-time external operation, click the button on the HARDWARE tab.
If the model is successfully built and downloaded to the target. Simulink will automatically connect and start the real-time code on the target and the button will automatically change to a button.
To stop the real-time code execution, click the button on the HARDWARE tab and Simulink will stop the real-time code on the target and disconnects from the target.
For additional information please refer to the following pages: