You can do this easily with the toolbox Simulink Test.
There you can create a test harness while not compiling the model, as you can see below:
More information can be found here:
"Create without compiling the model
Creating a test harness without compiling the model can be useful if you are prototyping a design that cannot yet compile. When you create a test harness without compiling the main model:
- Parameters are not copied to the test harness workspace.
- The main model configuration is not copied to the test harness.
- The test harness does not contain conversion subsystems.
Test harnesses for Subsystem models are created without compiling the model."
If you want to do this programmatically, you can use the command:
which is documented here:
Using this command, you can set the following option:
to 'true' or 'false'.