You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

OpenModelica图标视图中参数值无法正常显示问题咨询

问题解答

这不是操作错误,而是OpenModelica与Wolfram SystemModeler对图标文本变量引用的语法差异——%a是SystemModeler的专属扩展语法,并不属于Modelica标准规范,因此OpenModelica不支持这种写法。

在OpenModelica中,要在图标文本里显示参数值,需要通过字符串转换函数将参数转为字符串,直接赋值给textString。修改后的代码如下:

model temp
  parameter Integer a = 2;
equation
  annotation(
    Icon(graphics = {
      Rectangle(origin = {-6, 30}, extent = {{-50, 34}, {50, -34}}), 
      Text(origin = {-14, 37}, extent = {{-24, 11}, {24, -11}}, textString = String(a))}));
end temp;

这样修改后,图标视图里就能正确显示参数a的值2了。

内容的提问来源于stack exchange,提问作者gcoopermax

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 20:52:01