I am new to Modelica and am having trouble trying to sample a continuous, real, input signal to an array. I have tried using 'when sample' but can't get it to work. The problem with the code below is that every x[i] is an identical sampled version of p every dt seconds. What I would like, is x[1] to be the first sameple, x[2] to be the second sample and so on.
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;
for j in 1:10 loop
when sample(0, dt) then
x[j] = p;
end when;
end for;
end test_sample;
Any help would be greatly appreciated!
Thanks in advance!