3

I would like to display some information about a Simulink model, without first knowing the filename. The information will be displayed in the model itself.

Something similar, mfilename, is available for MATLAB programs. Is there an equivalent for Simulink models?

Matthew Simoneau
  • 6,199
  • 6
  • 35
  • 46
Craig
  • 991
  • 1
  • 13
  • 28

3 Answers3

4

Thanks to Edric I found bdroot, which gives the system name. Passing this to which makes Matlab find the model using it's search path.

So the solution is model_path = which (bdroot);

One problem is that if you have shadowed files this method may give the incorrect answer.

Craig
  • 991
  • 1
  • 13
  • 28
2

I think it may be more reliable to get the model parameter in case there is more than one matching model in your path:

model_path = get_param(bdroot, 'FileName');
Carl
  • 21
  • 2
0

I think you need gcs http://www.mathworks.com/help/toolbox/simulink/slref/gcs.html

Edric
  • 23,676
  • 2
  • 38
  • 40