How are math operations of constants in simulink models performed?
Mostrar comentarios más antiguos
Are the results calculated at every simulation step or are they calculated only once at the beginning of the simulation?
example:
If I have two constants a and b. In Simulink I call them through constant blocks and add them using an add block. Does the solver calculate this sum at each calculation step or does it calculate the sum only once?
Respuesta aceptada
Más respuestas (1)
Raj
el 2 de Mayo de 2019
0 votos
The computation is done at each simulation step time. So if you are adding two constant blocks, from t=start of simulation to t=end of simulation, Simulink computes the sum at each sampling time step.
4 comentarios
Thomas Ayres
el 2 de Mayo de 2019
This is not always true, as described in my original answer if you have a constant sample time for the 2 constants then the sum block will inherit this sample time and thus only compute the sum at the begining of the simulation. This can be observed by looking at a simulation profile report and changing between a constant and non-constant sample time.
Raj
el 2 de Mayo de 2019
I am not quite convinced. I still think Simulink computes output throughout the simulation. Consider this case for example:

Basically I am adding two constants but I am changing the value of second constant in the middle of simulation using a switch condition. If the sum was computed only in the beginning as you say then the summer output should have been a constant value. But that is not the case. The output is changing as you can see below:

Can you explain where I am going wrong here?
Thomas Ayres
el 2 de Mayo de 2019
In this case you are correct, the answer is not constant and is computed throughout, but this isn't the case asked by Michael. In your example you don't have 2 constants being added. The sample time of the signal coming from the switch will be driven by your signal builder block creating a varying signal. If you had Michaels example described above you could configure it to computer once or multiple times.
Michael Knörzer
el 3 de Mayo de 2019
Categorías
Más información sobre Simulink en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!