Why doesn't my sample time change?

7 次查看(过去 30 天)
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

采纳的回答

Sebastian Castro
Sebastian Castro 2018-1-26
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 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by