主要内容

add_block

Add block to model

描述

example

h= add_block(source,dest)adds a copy of the blocksourcefrom a library or model to the specified destination model and block name. This syntax creates the block at the same location as it appears in the model or the library model.

If you are copying between models or from a library, load the destination model first.

example

h= add_block(source,dest,'MakeNameUnique','on')确保目标块名称在模型中是唯一的。如果存在该名称的块,则此语法将一个数字添加到目标块名称,以确保唯一名称。

h= add_block(___,'CopyOption','nolink')copies the block or subsystemsourcefrom a library without creating a link to the library block.

example

h= add_block(sourceIn,destIn,'CopyOption','duplicate')duplicates an inport block in a subsystem, giving the destination block the same port number as the source block. Duplicate an inport to branch a signal from an input port without creating a port or adding lines. For more information, seeCreating Duplicate Inports.

example

h= (___,名称,值)uses optionalName,Value参数。

Specify optional comma-separated pairs ofName,Value参数。Nameis the argument name and价值是相应的值。Name必须出现在引号中。您可以按任何顺序指定几个名称和值对参数NAME1,Value1,...,Namen,Valuen.

add_blockfunction, you can use block parameter and value pairs. For a list of all the block parameters, seeCommon Block Properties特定于块的参数.

Examples

collapse all

Add the block from the Simulink®图书馆到模型f14.

Load or open the destination model.

open_system('f14');

Add theScopeblock from the Simulink Sinks library tof14, naming the new blockmyscope.

add_block('金宝appSimulink/angs/scope','F14/myscope');

添加一个copy of a block from the modelf14toVDP.

Load or open the destination model.

open_system('vdp');

Add the Actuator Model block fromf14toVDP.

add_block('f14/Actuator Model','vdp/Actuator Model');

Add the block from the Simulink library to the modelVDP. Because there is already a block named Scope inVDP, use theMakeNameUnique确保新块名称唯一的选项。

Load or open the destination model.

open_system('vdp');

Add theScopeblock from the Simulink Sinks library toVDP, ensuring that the name is unique.

add_block('金宝appSimulink/angs/scope','vdp/Scope','MakeNameUnique','on')

f14/Controllersubsystem that uses the same port number as another inport in that subsystem.

复制控制器子系统中的棍棒输入(in)块,命名Copy Stick Input(in)2。所得块使用与Stick Input(in)相同的端口号,但不会在父系中添加Inport。进入该端口分支的信号均可到达两个港口。

add_block('f14/Controller/Stick Input (in)',...'f14/Controller/Stick Input (in)2',“复制”,'duplicate')

添加一个block from a library to a model and set parameters using aName,Valuepair.

Load or open the destination model.

open_system('vdp');

添加一个获得block from the library toVDP, and set the获得value to5.

add_block(“金宝app simulink/数学操作/增益”,'vdp/Five',“获得”,'5')

Input Arguments

collapse all

要复制到模型的块,指定为:

  • The full block path if you are copying the block from another model, for example,'vdp/Mu'. This usage copies the block and its settings.

  • 图书馆块路径如果要从库中添加一个块,例如“金宝app simulink/数学操作/增益”.

    要获取库块路径,您可以将鼠标悬停在库浏览器中的块上。或者,您可以打开库模型,选择块并输入gcbat the command line. To open the library model, in the Library Browser, right-click the library name in the library list and selectOpenLibrary_name图书馆.

您也可以使用语法'内置/块状'as the source block path, where块状是编程块名称 -BlockTypeparameter (seeCommon Block Properties)。但是,使用'内置/块状'sometimes have different default parameter values from library blocks.

For subsystems and masked blocks, use the library block path. Using theBlockTypevalue (SubSystem)创建一个空子系统。

例子:'vdp/Mu','金宝appSimulink/angs/scope'

Name and location of the new block in the model, specified as the block path.

例子:'f14/Controller/MyNewBlock'

端口块其端口号要复制,指定为块路径。

例子:'f14/Controller/Stick Input (in)','myModel/mySubsystem/In1'

Inport block with duplicate port number to create, specified as the block path. Create the destination block in the same system as the source block.

例子:'myModel/mySubsystem/DupPortIn'

Output Arguments

collapse all

New block, returned as a handle.

在R2006a之前引入