MATLAB: Can I make the parameters of a UDP Send/Receive block tunable in Simulink

blockDSP System Toolboxparameterreceivesendsimulinktunabletuneudp

As of R2019b, the UDP Send / Receive blocks have the IP address and port specified in build-time. Is it possible to include these parameters as a dynamic input that can change in runtime?
One possible use-case for this workflow is to read the desired IP address from a file in runtime. This would allow flexibility in changing the IP and port without requiring a rebuild of the model.

Best Answer

There is currently no documented way to make the UDP send/receive block port parameter tunable in runtime/after building the model. Possible workarounds include:
- Place multiple UDP send/receive blocks. Place each in an enabled subsystem, triggered subsystem, or switch case action subsystem. If you know all possible ports that you may need to use, you can add a dedicated block for each port.
- For the receiving block, if the port is known but the IP isn't, you can set the receiver block to accept UDP packets from all IPs. Then use a SimEvents Message Receive block to separate out the different messages.
- Starting in R2020b, you can use the udpport, write, read functions as described in the following link, but inside of a MATLAB Fcn Block.
https://www.mathworks.com/help/releases/R2020b/instrument/send-and-receive-multicast-data-packets-using-udp.html