开发者

How can a Simulink model discover it's own filename and path?

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?开发者_Python百科


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.


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');


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜