1

I would like to simulate the following scenario with Simulink/Matlab(/Stateflow): A random number generator is running. Every 10 seconds the numbers that were generated during the last 10 seconds are added up. If the sum is greater than 50 the system is put into an unsafe state (simply a variable 'state' that initially is zero and then gets changed to one). Otherwise (sum <= 50), the state remains unchanged.

My problem is how to implement the 'parallelism' of keeping the random number generation going while analysing the generated data in the background. Any hints of how to do this are greatly appreciated!

This is how I would like the simulation to somehow look: enter image description here

ec-m
  • 111
  • 2
  • Simulink would appear to be gross overkill for a simple running window sum like this. – Carl Witthoft Sep 19 '17 at 13:20
  • This is simply an abstract version of what I am trying to achieve and for the whole truth I need Simulink - that's why I am asking ;) – ec-m Sep 19 '17 at 13:22
  • The problem is that number of steps is adaptive. – joojaa Sep 19 '17 at 13:36
  • @joojaa What exactly do you mean by that? – ec-m Sep 19 '17 at 14:25
  • When simulnk runs, it is not taking fixed timesteps (Altough it might return only timesteps of fixed inverval). So it may run faster in one part of the simulation than another. This will cause havoc with your scheme. – joojaa Sep 19 '17 at 17:57
  • @joojaa you can also choose a fixed time step solver in simulink, however this does not mean that the computation time will be the same. Or is the OP referring to the simulated time and not real world elapsed time? – fibonatic Sep 22 '17 at 13:22
  • @fibonatic, yes and your simulation can be fully discrete, yes. But as a general im going to simulate xyz and store random variables is not a good idea. However there exists a number of event based simulators where this may be a good general approach. perhaps this could be expressed as a rolling average though, since that would work no matter the stepping. – joojaa Sep 22 '17 at 16:11

0 Answers0