Hi Krishnan,
I understand that you want to generate C++/DPI code of a Simulink model from the UNIX command line.
Please note that the function ‘dpigen’ is used to generate SystemVerilog DPI component from a MATLAB function/code but not from a Simulink model.
In order to generate the C++ code of a Simulink model, kindly follow the workflow mentioned below:
- Create a MATLAB script to open the Simulink model and generate the C++ code. Consider the code below:
modelName = 'Model_Name';
set_param(modelName, 'TargetLang', 'C++');
set_param(modelName, 'GenCodeOnly', 'on');
For more information on the ‘slbuild’ function, kindly refer to the following documentation:
- To run any MATLAB function from the UNIX command line, MATLAB must be present in the system’s PATH. You can add MATLAB to the system PATH by entering the following command in the UNIX command line:
export PATH=$PATH:<path_to_MATLAB_bin>
- Verify the addition of MATLAB to the system PATH by entering the following command in the UNIX command line:
- Run the MATLAB script, from step-1, using the following command:
matlab -batch "run('path_to_MATLAB_script’)"
You can observe that a new folder (containing the C++ code) is created in the directory, where the MATLAB script is present.
Hope this helps!