Why doesn't my sample time change?
7 views (last 30 days)
Show older comments
Stellan Johansson
on 28 Nov 2017
Answered: Sebastian Castro
on 26 Jan 2018
Hello,
I have been given a Simulink model using a sample time of 0.1s. I want to add an S-function (.mexw64) that requires a sample time of 0.01s. However, trying to change the solver sample time to 0.01s doesn't seem to work. I get the following error:
The sample time period (0.01) of 'model block x' is not an integer multiple of the fixed step size (0.1) specified for model.
The error occurs for several model blocks, x, y, z, etc... In the model explorer, all configurations have the same sample times, 0.01s, but the error persists. I have found no program lines that change the sample time during excecution. Is there something I have missed?
BR Stellan
0 Comments
Accepted Answer
Sebastian Castro
on 26 Jan 2018
If you go to Simulation > Model Configuration Parameters, the "Solver" pane should have a sample time setting in there set to 0.1. The error you're getting is because the solver is running at a fixed step size of 0.1 second, but you're trying to go faster with certain blocks in the model.
You can either reduce that to a smaller value that will work, or if you plan to define sample times in blocks, just set it to "auto" and the model will choose a sample time based on the blocks.
Even better, create a MATLAB variable for sample time and use it both in the solver settings and your blocks. That way, you just change that value and everything in the model updates accordingly.
- Sebastian
0 Comments
More Answers (0)
See Also
Categories
Find more on Subsystems in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!