NetSim can be interfaced with MATLAB with the help of MATLAB Interfacing C file format and associated settings that are explained in NetSim User Manual and in related sample projects in NetSim File Exchange. For you to interface NetSim with MATLAB, initially analyze what parameters your algorithm in MATLAB expects as input. Identify the relevant parameters in NetSim to be passed to MATLAB. Identify whether your MATLAB codes are going to work instead of existing functionality (set of codes) available in NetSim or if it is going to do something in addition to what is already happening in NetSim. Make calls from relevant places of NetSim source code and read the values computed in MATLAB to tune the simulation variables in NetSim.


MATLAB Interfacing C file (refer NetSim User Manual) contains the following functions: 

fn_netsim_matlab_init() - This function is used to initialize the MATLAB Engine.

fn_netsim_matlab_run() -This is the function where MATLAB code is executed.

fn_netsim_matlab_finish() -This function is used to Close the MATLAB Engine.


Upon interfacing NetSim with MATLAB, 

  • NetSim can initialize a MATLAB Engine process at the start of the simulation, 
  • Can pass parameters to MATLAB workspace at runtime (either execute workspace commands or pass parameters to MATLAB .m files, perform computation or generate dynamic plots in MATLAB)
  • Can read parameters from MATLAB workspace
  • Can terminate the MATLAB engine parameter at the end of the simulation


Refer the following resources for further information:

1. NetSim User Manual - Section on Interfacing MATLAB with NetSim

2. NetSim File Exchange Projects related to MATLAB Interfacing in v12.1 - http://www.tetcos.com/file-exchange.html

3. NetSim Knowledgebase articles related to interfacing with other tools - https://tetcos.freshdesk.com/solution/folders/14000090960