Main Content

gcs

Get path name of current system

Syntax

Description

gcs returns the path name of the current system.

The current system is one of these:

  • During editing, the subsystem most recently clicked or that contains the block most recently clicked; if the most recent click is in the top level of the model hierarchy, the current system is the model.

  • During simulation of a model that contains an S-Function block, the subsystem containing the S-Function block currently being evaluated; if the S-Function being evaluated is in the top level of the model hierarchy, the current system is the model.

  • When a callback is invoked, the model, subsystem, or block executing the callback

  • During evaluation of the MaskInitialization function, the subsystem containing the block whose mask is being evaluated; if the mask is in the top level of the model hierarchy, the current system is the model.

  • The model most recently loaded into memory with load_system; only the first use of load_system makes the model the current system

To get the current model, use bdroot.

If you close the model that contains the current system, another open or loaded model becomes the current system. Use gcs to find out the new current system.

To explicitly set the current system, you can either:

  • Use set_param with the 'CurrentSystem' parameter on the root Simulink® model, for example:

    set_param(0,'CurrentSystem','mymodel')

  • Open the model by using open_system or the model name at the MATLAB® command prompt.

example

Examples

collapse all

Open the example. Then, open the sldemo_fuelsys/fuel_rate_control/airflow_calc subsystem.

load_system('sldemo_fuelsys')
open_system('sldemo_fuelsys/fuel_rate_control/airflow_calc')

Click the Pumping Constant block.

Get the path of the model that contains the most recently selected block.

gcs
ans = 
'sldemo_fuelsys/fuel_rate_control/airflow_calc'

Open the example. Then, load the f14 model.

load_system('f14')

Get the current system.

gcs
ans = 
'f14'

Load the vdp model.

load_system('vdp')

Get the current system.

gcs
ans = 
'vdp'

Clear vdp from memory.

close_system('vdp')

f14 becomes the current system because it was the current system before vdp.

To see the change, get the current system.

gcs
ans = 
'f14'

Version History

Introduced before R2006a

See Also

| |