OpenModelica 中的可变采样频率 [英] Variable sampling frequency in OpenModelica
问题描述
我指的是这篇文章:
我想测量具有可变采样频率的 RMS 值(或平均值),我可以将其作为输入信号输入.
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;
这会引发错误:可变性 CONST 的分量 f 具有更高可变性 VAR 的绑定 1.0 + abs(2.0 * asin(time)).
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?
推荐答案
f
的表达式是随时间变化的,但 f
被声明为 constant代码>.
The expression for f
is time-varying but f
is declared as constant
.
只需将 constant Real f = ...
替换为 input Real f = ...
.然后您可以从外部"指定 f
如果您愿意,可以选择模型.
Simply replace constant Real f = ...
with input Real f = ...
. Then you can specify f
from the "outside" of the model if you like.
这篇关于OpenModelica 中的可变采样频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!