Simulink time samples

11 visualizaciones (últimos 30 días)
somewhereondearth
somewhereondearth el 2 de Feb. de 2011
I am running my Simulink model multiple times from workspace. I change one parameter during the simulation (say at t=2 sec, I change the value of x parameter in Simulink model from 10 to 20). I have one s_function written in .m file to do that. The sampling time used in s-function is 0.001 sec.
I have set my input as sine wave with sampling time 0.001 sec.
Clearly, I have 50001 samples. It works for 2 runs (2 different parameters changed). But on the third go, it is giving me 50003 samples instead of 50001.
I checked the time samples and it turns out that it is having some problem around time when parameter is being changed.
For a normal (t=0:0.001:50) command, it is giving me following time samples (around 2 sec):
1.9990 2.0000 2.0010 2.0015 2.0020 2.0028 2.0030 2.0040 2.0050 2.0060 2.0070
But my Simulink model is returning following:
1.9990 2.0000 2.0010 2.0020 2.0030 2.0040 2.0050 2.0060 2.0070 2.0080 2.0090
I have set all the other blocks which have option for sampling time to -1 in the Simulink model.

Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 3 de Feb. de 2011
It is likely that the change of parameter is causing a zero-crossing to occur around t=2, thus forcing the solver to take smaller steps. You can either turn off zero-crossing detection, or, switch to a fixed-step solver if you prefer having a fixed number of time-steps (although that may compromise the accuracy of your data if your system has significant chatter).
  2 comentarios
somewhereondearth
somewhereondearth el 3 de Feb. de 2011
I turned off the zero-crossing detection but did not helped. I will look around other options before trying the fixed-step solver since I am using pause command in the s function.
Thank you
Kaustubha Govind
Kaustubha Govind el 3 de Feb. de 2011
Variable-step solvers compute the next time-step depending on the model dynamics (even without zero-crossing detection), to achieve the given error tolerances. If having the exact number of time-steps is important to you, then the most definite way is to choose a fixed-step solver.

Iniciar sesión para comentar.

Más respuestas (1)

Rob Graessle
Rob Graessle el 3 de Feb. de 2011
Is there a reason that you couldn't use a fixed-step solver (with step size 0.001s) instead of a variable-step solver? That way you would be guaranteed to get 50001 samples on any simulation.
Aside from that, it isn't obviously clear why changing one parameter would add time steps to the simulation (I would have to examine the model further). You could use the Simulink Debugger to inspect the simulation execution around t=2 to see exactly what is going on.
  1 comentario
somewhereondearth
somewhereondearth el 3 de Feb. de 2011
The model changes the parameter at t=2 sec (using set_param, pause and continue in the s function). But I have observed that for a particular parameter (or parameters) it samples at t= 2.0015 and 2.0028 ( the two extra samples) along with the other normal sampling instants.
I am digging into the Debugger now. I will also try the fixed-step solver nothing works out.
Thank you

Iniciar sesión para comentar.

Categorías

Más información sobre General Applications en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by