主要内容

本页采用了机器翻译。点击此处可查看最新英文版本。

synchronizeChanges

同步更改分配集中的模型

    说明

    synchronizeChanges(allocSet) 会同步分配集源模型或目标模型中的任何更改。

    示例

    示例

    全部折叠

    此示例显示了如何同步分配集中所用模型的更改。

    创建两个新模型,每个模型有一个组件。

    mSource = systemcomposer.createModel('Source_Model_Allocation');
    systemcomposer.openModel('Source_Model_Allocation');
    sourceComp = mSource.Architecture.addComponent('Source_Component');
    mTarget = systemcomposer.createModel('Target_Model_Allocation');
    systemcomposer.openModel('Target_Model_Allocation');
    targetComp = mTarget.Architecture.addComponent('Target_Component');

    创建名称为 MyAllocation 的分配集。

    allocSet = systemcomposer.allocation.createAllocationSet('MyAllocation',...
         'Source_Model_Allocation','Target_Model_Allocation');

    获取默认分配方案。

    defaultScenario = allocSet.getScenario('Scenario 1');

    在模型之间分配组件。

    allocation = defaultScenario.allocate(sourceComp,targetComp);

    用新组件更新模型。

    sourceComp2 = mSource.Architecture.addComponent('Source_Component_2');
    targetComp2 = mTarget.Architecture.addComponent('Target_Component_2');

    同步分配集中模型的更改。

    synchronizeChanges(allocSet)

    在模型之间分配新组件。

    allocation2 = defaultScenario.allocate(sourceComp2,targetComp2);

    打开分配编辑器。

    systemcomposer.allocation.editor

    排列模型,使组件显示在画布上。

    Simulink.BlockDiagram.arrangeSystem('Source_Model_Allocation')
    Simulink.BlockDiagram.arrangeSystem('Target_Model_Allocation')

    保存模型和分配集。

    save(mSource)
    save(mTarget)
    save(allocSet)

    输入参数

    全部折叠

    分配集,指定为 systemcomposer.allocation.AllocationSet 对象。

    详细信息

    全部折叠

    版本历史记录

    在 R2020b 中推出