As of R2024b, you can use the built-in blocks:
For releases prior to R2024b, please consider the following:
Modbus communication over TCP/IP or Serial RTU is available in MATLAB as part of Industrial Communication Toolbox (in R2017a through R2021b, as part of Instrument Control Toolbox).
There are two workarounds for supporting Modbus communication in Simulink: There is an attached example model which shows how this approach might be implemented. Since MATLAB function blocks generate code, it is necessary to use "coder.extrinsic" on the MODBUS functions to instruct the code generator to skip these functions. More information on "coder.extrinsic" can be found here: https://www.mathworks.com/help/simulink/slref/coder.extrinsic.html Also, note that we only create the Modbus object once by declaring it as a persistent variable. Because of this, you cannot use multiple of the Modbus read blocks within your model. It would be necessary to add extra logic to use multiple read blocks, so only one Modbus object is created for use by all blocks.