In a model, I programmed a little algorithm (gradient algorithm). This algorithm is not complex but it works with discrete time in a continuous simulation. So, I would like to use the timeevent function each 2s (for example) in my model and for this time, I would like to calculte my algorithm.

For the moment, as i didn't manage to do this, I repeat several times the timeevent function but I can not do it 30 times...

Consequently, I try to use the frequencyevent function (like explained in the discretevent model). I have used this code :

Code: Select all

`output = frequencyevent (periodTime, offsetTime);`

i=0;

if output==1 then

i=i+1;

end;

next (total) = total + output*sampletime;

sortie = total + initial;

The problem of this code is that the sampling leads the program an error in my simulation. The error underlines me that the issue is linked to derivative functions associated to discrete time.

Consequently, I would like to use only the fonction timeevent but without having a sampling (visible with the discrete tab).

Question:

Do you have some ideas to use the timeevent function each T second but without having sampling ?

Thanks a lot for your help.

I hope my post will be clear enough.