Using the Simcenter Amesim to Simulink Interface
Running batch simulations within Simulink
You might want to run multiple simulations on a Simulink model into which you have imported a Simcenter Amesim S-function, either using the co-simulation interface (AME2SLcosim) or the model exchange interface (AME2SL). You can do this with a simple MATLAB script. This is because a Simcenter Amesim S-function behaves like a standard S-function. As a consequence, you can conveniently leverage MATLAB workspace parameters to execute batch simulations on parameters exposed by the Simcenter Amesim S-function. A recommended workflow is:
Create a workspace parameter for each parameter whose value you wish to change during a batch simulation.
Log all the required signals for results analysis (this step is also necessary for the Simulation Data Inspector in Simulink).
Set custom names for these signals whenever needed.
Run a MATLAB script containing the desired simulation loop.
Post-process the results.
Example of model with logged signals
In this example, we reuse the skyhook example used previously. We can log signals as shown in figure Figure 40.
Figure 40: Skyhook model with logged signals for result analysis
Example of MATLAB script for batch simulations
The MATLAB script provided below is a very basic way of performing batch simulations on the body mass parameter of the model above. The body mass value is defined as a MATLAB workspace parameter and varied between two limits. The result to be plotted is the car body displacement.
Figure 41: Basic MATLAB script performing batch simulations
Copy
% Specify Simulink model name
% Log desired signals and use custom names if needed
simulink_model_name = 'skyhookModel';
% Number of simulations (batch runs)
N = 10;
% Definition of batch parameters and their values
body_mass = 400; % Default value (re-)create workspace parameter
min_value = 100;
max_value = 600;
batch_values = linspace(min_value,max_value,N);
% Initialize simulation inputs and outputs
simIn(1:N) = Simulink.SimulationInput(simulink_model_name);
% Initialize figure(s) and labels for legend(s)
figure; hold; cmap = jet(N); labels = {};
% Loop for batch simulations
for i = 1:N
body_mass = batch_values(i); % applying parameter values
simOutputs(i) = sim(simIn(i)); % simulating
% Extracting desired results (3rd logged variable here)
time = simOutputs(1,i).logsout{3}.Values.Time;
rod_displacement = simOutputs(1,i).logsout{3}.Values.Data;
plot(time,rod_displacement,'color',cmap(i,:));
labels{i} = strcat('M_{body}=',num2str(batch_values(i)));
end
% Adding title(s) and legend(s) for final plot(s)
title(simOutputs(1,1).logsout{3}.Name);
legend(labels);
hold;
This script is very basic but can be used as a starting point to run batch simulations on a Simulink model containing a Simcenter Amesim S-function. You should adapt it to your specific requirements. For more advanced examples, please refer to the Simulink documentation provided by MathWorks.
Batch simulation results obtained with the previous script
The curves obtained for the 10 simulations performed on the skyhook example are shown below.
Figure 42: Batch simulation results: car body displacement
Warning
Since using the Simcenter Amesim to Simulink interface means that the simulation is completely managed by Simulink, you must make sure you create a sequential simulation loop and not a parallel one (a standard “for” loop instead of a “parfor” loop). If this is not the case, write conflicts may arise concerning Simcenter Amesim results files or other auxiliary files.
Note
When Simulink is the master tool, the Simcenter Amesim result file from a previous simulation is always overwritten by the next. However, if you wish to take advantage of Simcenter Amesim's built-in batch-run functionality (providing the ability to save multiple result files and the associated post-processing capabilities), you must choose the Simulink to Simcenter Amesim interface (SL2Amecosim). In this case, you can execute batch runs within the Simcenter Amesim environment. In this case there is no difference from a Simcenter Amesim model containing no Simulink components.
Source: https://docs.sw.siemens.com/en-US/doc/254352342/PL20250521841123434.amesim_collection.Simulink/xid2288148 · retrieved 2026-07-17