【问题标题】:Using a Simulink SimulationInput Object as a property of a class使用 Simulink SimulationInput 对象作为类的属性
【发布时间】:2020-02-16 07:06:45
【问题描述】:

我想设置一个类的对象,它包含 simulink 模型的所有变量作为其属性。

为了以后能够使用并行仿真,我希望在方法中有一个函数,它获取所有属性并将它们提供给 Simulink SimulationInput 对象(通过“setVariable”方法), 但是当我运行它时,setVariable-function 不会填充对象的变量。

代码看起来有点像这样:

classdef SimSetup

properties
    mdl                        = 'SimulinkFile'
    SimulationTime             = 2
    Plant
    in
end

methods
    function this = SimSetup()
        open_system(this.mdl);
        this.Plant = load('PlantData.mat','xPlant');
    end

    function createSimIn(this)
        this.in = Simulink.SimulationInput(this.mdl);       
        this.in = this.in.setVariable('SimulationTime', this.SimulationTime);
    end
end

提前致谢

【问题讨论】:

  • 为此目的预定义了SimulationInput对象:de.mathworks.com/help/simulink/ug/…
  • 是的,我知道。这就是我在函数 createSimIn() 中所指的内容。正如您所提议的,我正在创建一个 SimulationInput 对象。

标签: matlab simulink


【解决方案1】:

错误如下:

我要么必须使用句柄类,要么必须将函数的输出返回给对象本身(简而言之:function this = createSimIn(this))。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-08
    • 1970-01-01
    • 2016-04-09
    • 2017-01-25
    • 1970-01-01
    • 2020-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多