【问题标题】:Increment of Variable goes wrong变量的增量出错
【发布时间】:2013-02-26 08:32:04
【问题描述】:

变量现在从 j = 1 开始,但增量是错误的。对于 t = 0.5,它的值应该是 2,对于 t = 1,j = 3 等等...... 您会在下图中看到错误

class abc

import Modelica.SIunits;

parameter SIunits.Time delta_t = 0.5;

constant Real a[:] = {4,2,6,-1,3,5,7,4,-3,-6};

Real x;
Integer j(start=1);
Integer k = size(a,1);

algorithm
when {(sample(delta_t, delta_t) and j < k),j == 1} then

     x := a[pre(j)];
     j := pre(j) + 1;

end when;
end abc;

提前致谢。

【问题讨论】:

    标签: modelica dymola


    【解决方案1】:

    当我将你的代码放入 Dymola 2013 时,我得到的正是你所期望的,j==2@time==0.5

    这个情节从何而来? Dymola 不会生成这样的图,因为 j 是离散变量。

    【讨论】:

      【解决方案2】:

      好的,我发现了问题。 Dymola 可以生成这样的图,这取决于输出设置。上面的图是在没有设置“在事件中存储变量”的情况下生成的,当我设置它时,我得到了正确的结果。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-03-19
        • 1970-01-01
        • 2023-03-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-04-30
        相关资源
        最近更新 更多