Question
Hi! I have a simulink model that I need to simulate over a few different durations and with a fixed (but different) sampling time. So what I want to do is to set this from the command line without having to start up simulink and change it manually each time. To clarify I want to set the simulation duration (or the start time/stop time) and the solver options to Fixed-step (or at least change the step-size). So it would look something like this in a script/the command line: sim('simModel', 'simulationTime', [0 10], 'solverOptions.stepSize', 1/1024) Where 'simModel' is the simulink model in question. It doesn't have to look like this, but just to give you an idea of what I want to do. Is there a way to do this? I can't really find it in the documentations, the only thing I find is how to set the sampling time for a specific block, but I want to keep those as inherited.
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 23, 2026
If you open the model's Configuration Parameters, for each parameter you can right-click and select "What's This?". This will open up some documentation, which includes a table that shows you how to programmatically use that parameter.
So, you can take that and use it in the sim command as you specified:
>> sim('modelName','StartTime','0','StopTime','10','FixedStep','0.2');
Notice that the properties have to take a string value and not a numeric value. This is where the num2str function comes in handy. For example,
for Ts = 0.01:0.01:0.1
simout = sim('modelName','FixedStep',num2str(Ts));
end
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related simulink Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →