Main Content

gcb

Get path name of current block

Description

example

bl = gcb returns the full block path name of the current block in the current system. The current block is:

  • The most recently clicked block

  • The S-Function block currently executing its corresponding MATLAB® function

  • The block whose callback routine is being executed

  • The block whose mask is being evaluated as part of the MaskInitialization parameter evaluation

  • The last block loaded after opening a model

example

bl = gcb(sys) returns the full block path name of the current block in the specified system. Load the system first.

Examples

collapse all

Get the path name of the most recently selected block and of the first block selected by a selection box you draw around multiple blocks.

After Selecting One Block

Open the example. Then, open the vdp model.

open_system('vdp')

In the model, select a block. For example, select the Constant block.

Then, enter this command in the MATLAB® Command Window.

gcb
ans = 
'vdp/Out2'

After Drawing a Selection Box Around Multiple Blocks

When you made your most recent selection by drawing a selection box around multiple blocks, the gcb function returns the first block you selected with the selection box.

In the model, select multiple blocks. For example, draw a selection box that first encompasses the masked subsystem block named Mu, and then multiple other blocks in the model.

Then, enter this command in the MATLAB Command Window.

gcb
ans = 
'vdp/Out2'

Open the example. Then, open the vdp model.

open_system('vdp')

In the model, select the Constant block.

Use the get_param function to get the Constant value. Specify which block to get the Constant value of using the gcb function.

get_param(gcb,'Value')

Open the example. Then, open the sldemo_fuelsys model.

open_system('sldemo_fuelsys')

Get the current block in the fuel_rate_control subsystem.

b = gcb('sldemo_fuelsys/fuel_rate_control')
b = 
'sldemo_fuelsys/fuel_rate_control/fuel_rate'

Input Arguments

collapse all

System that contains the block, specified as a character vector.

Example: 'vdp' 'sldemo_fuelsys/fuel_rate_control'

Version History

Introduced before R2006a