Main Content

bdroot

Top-level model of current system

Description

example

model = bdroot returns the top-level model of the current system. The current system is the currently active Simulink® Editor window or the model in which a block is selected.

example

model = bdroot(elements) returns the top-level model of the specified model elements. Before using bdroot, make sure the top-level model of each element in elements is loaded.

Examples

collapse all

Open the example. Then, in the f14 model, open the subsystem named Controller.

load_system('f14')
open_system('f14/Controller')

Get the top-level model of the current system.

bdroot
ans = 
'f14'

Open the example. Then, open the f14 model.

open_system('f14')

In the model, interactively select a block.

Get the top-level model of the selected block. Use the gcb function to specify the selected block.

bdroot(gcb)
ans = 
'f14'

The function returns a character vector that specifies the name of the top-level model.

You can also specify the block as a handle. Get the handle of the current block.

h1=getSimulinkBlockHandle(gcb)
h1 = 507.0016

Get the top-level model of the selected block.

h2=bdroot(h1)
h2 = 0.0022

The function returns the handle of the top-level model. To get the name of the top-level model, pass the handle of the top-level model to the getfullname function.

getfullname(h2)
ans = 
'f14'

Input Arguments

collapse all

Model or model elements whose top-level model to return, specified as a handle, model name, model path or block path. Specify a model name, model path, or block path using character vectors or a string. Specify multiple model names, model paths, or block paths as cell arrays of character vectors or a string array. Specify multiple handles as a numeric array of handles.

Tip

Use bdroot with gcs, gcb, and gcbh to get the top-level model of the current system or block.

Output Arguments

collapse all

Top-level model. If the input argument is a handle, the function returns the handle of the top-level model. If the input argument is not a handle, the function returns the name of the top-level model, expressed as a character vector. If the input was an array, model is returned as an array of the same type as the input.

Version History

Introduced before R2006a

See Also

| |