Why does the simulation graph change when I change the step size?

1 view (last 30 days)
Hello everyone, I encounter some problems when I simulate the diff model as a fixed step solution.
First,i cant use numbers like 0.5,1,2,im getting error like this;
All sample times in your model
must be an integer multiple of the fixed-step size.
Second:When i changed the step size ,my simulations data is changing.
step-size = 0.1
step-size=0.01
what should i do to make it right ?
Thank you in advance for your help.

Answers (1)

Zinea
Zinea on 15 May 2024
Here are the solutions to the issues you are facing while simulating the diff model:
Sample times must be an integer multiple of the fixed-step size.
  • All the blocks in the model must have sample times that are integer multiples of the chosen fixed-step size of the solver. This can be done by double-clicking on the block and adjusting the sample time in the block parameters. If you are using a fixed-step size of 0.01, for example, valid sample times for all blocks would be 0.01, 0.02, 0.03, and so on.
  • For differential models, consider using a fixed-step solver that is suitable for stiff or non-stiff differential equations, depending on the model’s characteristics. For non-stiff problems, ‘ode4’ (Runge-Kutta) or ‘ode3’ (Bogacki-Shampine) might be suitable. For stiff problems, ‘ode14x’ may be used.
Changing simulation output with a change in step size.
  • A smaller step size generally yields more accurate results for differential models because it captures the dynamics more precisely. However, this comes at the cost of an increased computational load. In the diff model used in your case, changing the step size from 0.1 to 0.01 significantly alters the simulation results, which indicates that the model is sensitive to the step size, and a smaller step size is likely necessary for accurate simulation.
  • You may experiment with various fixed-step solvers available in Simulink and compare the results to choose the most accurate solver for your model.
Here are some links to get more information on fixed-step solvers and choosing step size:
Hope it helps!

Categories

Find more on Dependency Analysis in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!