Simcenter Prescan How to compile an executable and run a Prescan experiment on Windows without Matlab/Simulink and Prescan (For prescan up to version 2021.3)



Creating standalone executable of an Prescan experiment for Windows. The executable can be deployed and run on any other machine. (For prescan up to version 2021.3)


How to compile an executable and run a Prescan experiment on Windows without Matlab/Simulink and Prescan.
(For prescan up to version 2021.3)

Software needed:
Simcenter Prescan
Matlab Simulink with C++ compiler (Visual studio)
Perl Interpreter ( ) freeware

After creating the experiment with the Prescan GUI  and starting Matlab, open the Simulink model for generating code for Windows or Linux.
Click on the Prescan tab on the Simulink Model and click on Generate code for Target. A window will pop up for some settings. In here it is only needed to choose for which target code should be generated. Windows, Linux, or other hardware. In this case the process is shown for Windows. Click on build. In the Matlab command section you can see if the build process was successful or aborted.

User-added image

User-added image

Processing generated Zip-file: Creating windows exectable

After building, a zip-file will be stored in your experiment folder with the same name. This now needs to be processed to create an executable which then can be run on windows without Matlab and Prescan started.

Note: If the experiment zip file was generated with MATLAB 2016b or older, modify the following two files:

1. Modify the PERL makefile (unzip dir = directory of unzipped files):
<unzip dir>\<experiment name>\<model name>_ps_rtw\ Specify the full path to the installed PERL executable in this file.

2. Inspect and (if required) modify the Visual Studio x64 setup file:
<unzip dir>/<experiment name>/<model name>_ps_rtw/
Typically, you need to modify this file only if Prescan is installed at a different location than originally specified when the zip file was generated.

Note: If using Prescan 2021.1 and lower follow number 1, else number 2.

1. Open a 64 bit Visual Studio x64 Command Window in the makefile directory in the expanded zip and run nmake:
(cd = Command change directory to ) 
> cd <unzip dir>/<experiment name>/<model name>_ps_rtw                                                                      
> nmake -f

User-added image

2. Open the command shell via the process Manager of Prescan and configure the shell to be able to use the Visual Studio compiler, for example:
> call "C:\apps\MVS14\VC\vcvarsall.bat" amd64
2.1 Change directory into the generated code folder inside the experiment and run the build command:
> cd <unzip dir>/<experiment name>/<model name>_<target version>_rtw
> prescanbuild

After a successful build an executable with the same name as the model (with file extension .exe) will be present in <unzip dir>\<experiment name>
Close the Visual Studio x64 Command Window

Open a Prescan command shell window by pressing the "Shell" button in the Prescan Program Manager.
This opens a Windows terminal with several Windows environment variables set that identify your Prescan installation.

User-added image

In the shell, change directory to the experiment directory in the expanded zip file:
> cd <unzip dir>\<experiment name>

User-added image

Use the prescanrun script to launch the generated executable:
prescanrun <model name>.exe

This executable now can be deployed to any windows machine on which the process Manager is installed. There is no need to start up any other software to run the executable.
Note: For getting results after the execution. It is needed to take care of the data storing before generating the zip file.


KB Article ID# KB000049075_EN_US



Associated Components

Documentation Installer License Software