I am not 100% sure what you are trying to do. Are you trying to keep the 10 last samples in the array? If so, it is the code below (x[1]
is always the last sample). It is also possible to use sample(j*dt/10, dt)
or something similar to sample them all at different points in time (if you want n number of samples, but do not want the first one to always be the latest sample).
model test_sample parameter Real dt = 0.1 "Precision of monitor"; Real p; Real[10] x; Modelica.Blocks.Sources.Sine sine(freqHz=1); equation p = sine.y; when sample(0, dt) then x[1] = p; for j in 2:10 loop x[j] = pre(x[j-1]); end for; end when; end test_sample;