Main Content

gcs

Get path name of current system

Syntax

gcs

Description

example

gcsreturns the path name of the current system. The current system is one of these:

  • During editing, the system or subsystem most recently clicked or that contains the block most recently clicked

  • During simulation of a system that contains an S-Function block, the system or subsystem containing the S-Function block currently being evaluated

  • During callbacks, the system containing any block whose callback routine is being executed

  • During evaluation ofMaskInitialization, the system containing the block whose mask is being evaluated

  • The system most recently loaded into memory withload_system; only the first use ofload_systemmakes the model the current system

The current system is the current model or a subsystem of the current model. Usebdrootto get the current model.

If you close the model that contains the current system, another open or loaded system becomes the current one. Usegcsto find out the new current system.

To explicitly set the current system, you can either:

  • Useset_paramwith the'CurrentSystem'parameter on the root Simulink®model, for example:

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

  • Open the model by usingopen_systemor the model name at the MATLAB®command prompt.

Examples

collapse all

返回系统的路径that contains the most recently selected block.

Open theModeling a Fault-Tolerant Fuel Control Systemexample modelsldemo_fuelsys. Open the subsystem To Controller.

openExample('simulink_automotive/ModelingAFaultTolerantFuelControlSystemExample') sldemo_fuelsys open_system('sldemo_fuelsys/To Controller')

Click theRate Transitionblock. Get the current system.

gcs
ans = 'sldemo_fuelsys/To Controller'

Open the modelf14and get the current system.

f14 gcs
ans = 'f14'

Load the modelvdpusingload_system. Then get the current system.

load_system('vdp'); gcs
ans = 'vdp'

To removevdpfrom memory, close it. In this example, the current system becomes the open model,f14.

close_system('vdp'); gcs
ans = 'f14'

Version History

Introduced before R2006a

See Also

||