主要内容

replace_block

Replace blocks in金宝appmodel

Description

example

replBlks= replace_block(sys,current,新的)replaces the blockscurrentin the modelsyswith blocks of type新的。您可以使用Simulink的块金宝app®库或另一个模型作为替换块。

加载模型sysbefore using this function. The function prompts you to select the blocks you want to replace from a list of blocks that match thecurrent争论。

Tip

在使用此命令之前保存模型。

example

replBlks= replace_block(sys,Name,Value,新的)replaces the blocks that match the block parameters specified by theName,Valuepair arguments. You can also usefind_systemName,Valuepairs to qualify the search for blocks to replace.

将可选的参数对Name1=Value1,...,NameN=ValueN, whereNameis the argument name and价值is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

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

要指定有关要替换块的搜索块的其他信息,您可以使用find_systemName,Value在块参数之前对。例如,您可以使用'CaseSensitive','off'为了搜索块案例不敏感或'FollowLinks','on'to follow links into library links. Seefind_system对于那个清单Name,Valuepairs.

example

replBlks= replace_block(___,'noprompt')replaces the blocks without prompting you to select them from a dialog box.

Examples

collapse all

Replace blocks in the'vdp'model.

加载模型'vdp'

load_system('vdp');

Replace获得集成商块。

RepNames = replace_block('vdp','Gain',“集成商”);

A dialog box prompts you to select the blocks you want to replace.

Withvdp/Muselected in the dialog box, click好的

ReplaceScopeTo Workspace块。

RepNames = replace_block('vdp','Scope','simulink/Sinks/To Workspace');

A dialog box prompts you to select the blocks you want to replace.

Withvdp/Scopeselected in the dialog box, click好的

Replace blocks in theUnlockedsubsystem of thesldemo_clutchmodel. Replace blocks whose获得参数设置为bv

加载模型sldemo_clutch

openexample('sldemo_clutch');

在里面“解锁”subsystem, replace blocks whose获得值是bvwith集成商块。

replace_block('sldemo_clutch/Unlocked','Gain','bv',“集成商”);

A dialog box prompts you to select the blocks to replace.

Withsldemo_clutch/Unlocked/VehicleDampingselected in the dialog box, click好的

加载模型f14

load_system('f14')

Replace Gain blocks with Integrator blocks. The command returns the blocks it found to replace and replaces the blocks.

repl = replace_block('f14','Gain',“集成商”,'noprompt')
repl =13x1 cell{'f14/Aircraft...' } {'f14/Aircraft...' } {'f14/Aircraft...' } {'f14/Aircraft...' } {'f14/Controller/Gain' } {'f14/Controller/Gain2'} {'f14/Controller/Gain3'} {'f14/Gain' } {'f14/Gain1' } {'f14/Gain2' } {'f14/Gain5' } {'f14/Nz pilot...' } {'f14/Nz pilot...' }

Select a block that is a library link. Follow the library links and replace获得集成商与in them.

replace_block(gcb,'FollowLinks','on','BlockType','Gain',“集成商”,'noprompt')

Input Arguments

collapse all

其替换块的模型名称,指定为字符向量。如果指定模型,则命令将替换匹配模型中的所有块。如果指定子系统,则命令将替换该子系统中的块。

Example:'vdp','sldemo_fuelsys/fuel_rate_control'

Type of block to replace, specified as aBlockType或者MaskType价值。要查找块类型,请选择块,然后在命令提示符下输入:

get_param(gcb,'blocktype')

对于蒙版块,要查找蒙版类型,请选择块并输入:

get_param(gcb,'MaskType')

Block to replace the current block, specified in one of these forms:

  • BlockType替换块的值。指定此值使用库块作为替换块。

  • MaskType替换块的值。指定此值使用库块作为替换块。

  • Library path of the replacement block, for example,'simulink/Sinks/To Workspace'。Hover over the block in the library to see the library path.

  • 例如,来自其他模型的块名称,例如'vdp/Mu'。使用此值从模型中的另一个模型重复使用一个块的实例。

Output Arguments

collapse all

Blocks returned by thecurrent参数为字符向量的单元格数组返回。该函数返回值,无论您是否完成替换。

Version History

在R2006a之前引入