Page 1 of 1

Delay of random pulses

Posted: Mon May 22, 2023 6:15 pm
by aalto-comnet
Hi!

Attached you can find a model that creates pulses of random height and frequency. What I am trying to do, is to create a delay of these pulses, so that each pulse moves to the position of the next pulse, as shown in the attached figure.

However, in the current model, this is only possible when the multiplier = 1, which keeps the repeat time (i.e. the frequency) constant. For any multiplier > 1, the repeat time becomes random, and so does the delay, since the pulse train function and the delay are based on the same repeat time.

Any ideas as of how could this be possible, even without a delay but with another approach..?

Thanks! :D

Re: Delay of random pulses

Posted: Tue May 23, 2023 7:05 am
by Administrator
I don't see how you can ever do it. You don't know when the next pulse is (as it's random), so you cannot delay the first pulse so it lines up with the 2nd.

One thing you might be able to do is to sample the time at which the next pulse happens when you generate the first pulse. That would give you the delay time. That's the only way I can think of to do this.

Re: Delay of random pulses

Posted: Tue May 23, 2023 6:46 pm
by aalto-comnet
Hi, and thank you for your time and feedback! :D

Knowing that there is a high chance that this can eventually never be possible is already very useful as it saves me time and effort from trying to make it happen!

May I kindly ask for some clarity though with respect to your suggestion..? I assume that what you mean is to have some Delay Variable with a SAMPLE IF TRUE function, such as:

Delay Variable = SAMPLE IF TRUE ( condition , random pulse train , random pulse train )

and then 'feed' this Delay Variable as the delay time to the Delay Fixed variable.

But what could be the condition to sample the time at which the next pulse happens when the first pulse is generated..?

Thank you once again! :)

Re: Delay of random pulses

Posted: Tue May 23, 2023 8:03 pm
by tomfid
What's the purpose of this? If we knew, there might be some easier alternative.

You could certainly use SAMPLE IF TRUE, or the equivalent stock formulation, to store the height of the previous pulse, until needed when the next one occurs.

Re: Delay of random pulses

Posted: Tue May 23, 2023 8:14 pm
by tomfid
Try this?
pulse.mdl
(2.56 KiB) Downloaded 135 times

Re: Delay of random pulses

Posted: Tue May 23, 2023 8:43 pm
by aalto-comnet
Hi tomfid, and thank you for your answer and model!

You are right, there might be an easier way, so let me clarify. The purpose is to use the pulses as inflow and outflow for the same stock. Every time a new pulse goes in the stock, the previous pulse should come out of the stock. This is why I was trying to create a delay.

I am currently trying to understand what happens in the model you shared, but if you think there could be an easier way, I would be happy to know..!

Thank you again! :)

Re: Delay of random pulses

Posted: Tue May 23, 2023 9:25 pm
by tomfid
Ah, that makes sense. Pretty sure my example would work. If the entirety of the stock always flows out, then there's a simpler way.
pulse2.mdl
(5.91 KiB) Downloaded 135 times

Re: Delay of random pulses

Posted: Wed May 24, 2023 3:10 pm
by aalto-comnet
Hi Tom, and thank you very much for your feedback and models!! :D

The behaviour that I was looking for is already there in the first model that you shared! It's the 'previous pulse height' stock!

If you double check the second model, you will notice that the behaviour of all three stocks is the same (just a small mismatch in the initial value)!

Sorry that I did not catch you before you put more effort for the second version, I was apparently thinking about it in a much more complicated way..!

Once again, thank you so much, this was very useful overall! :)