You can generate a MATLAB script from your Modbus Explorer session, and then run it at the command line using the Instrument Control Toolbox™ Modbus functionality. The generated script contains your device configuration, all the read operations that you perform, the last write operation that you perform for each register type, and cleanup tasks.
Note that generating a script is not the same as saving the contents of the Read Register table. To do that, use Export as described in Read Coils, Inputs, and Registers in the Modbus Explorer.
To generate a script from your Modbus Explorer session, click Generate Script in the toolstrip. The script appears in the MATLAB Editor as a live script. To keep the generated script, save it in the editor. An example of a script is shown here.
Create Modbus Connection - This section of the generated script
modbus object using the configuration properties
Perform Modbus Reads - This section of the script performs all the Modbus reads that were done in your session. In this example, five reads were performed.
Perform Modbus Writes - This section of the script shows the last Modbus write operation that was done in the session for each register type. It is presented as a comment so that you must intentionally uncomment it to do the write, to prevent unexpected actions on your device.
Clean Up - This section of the script clears the
modbus object and releases the Server ID.