I am referring to this post:
alternative to sample function with varying sampling range
I want to measure an RMS value (or a mean value) with a variable sampling frequency, which i can feed in as an input signal.
The suggested way which nearly suits my need is the following:
model RMS
constant Real f_max = 2*2*asin(1.0);
constant Real f = 1+abs(2*asin(time));
Real signal = sin(time);
Real rms = if time < f then (if time < 1e-10 then signal else sqrt(i_sq / time)) else sqrt(i_sq_f / f);
Real i_sq(start=0, fixed=true);
Real i_sq_f = i_sq - delay(i_sq, f, f_max);
equation
der(i_sq) = signal^2;
end RMS;
This one throws the error: Component f of variability CONST has binding 1.0 + abs(2.0 * asin(time)) of higher variability VAR.
Is there a way to solve this problem and feed in the frequency as a real input value?