How to get the source directory from command window?

4 ビュー (過去 30 日間)
Shameer Parmar
Shameer Parmar 2013 年 2 月 24 日
Hello friends,
I have one simulink model opened in my matlab. I know the source directory of that model (.mdl file) and it is different than my current directory. (This is I manually changed). Now I want to know the path of that source directory from command window. Do you know how to get path of source directory.
on More information, we can see the reuired path into
'File' Menu >> Model Properties >> 'Main' Tab >> 'Source File'
How to get it? Please help me..
Thanks in advance..

採用された回答

Shameer Parmar
Shameer Parmar 2013 年 2 月 25 日
The resolution is..
>>bdroot
>>filename = strcat(bdroot, '.mdl')
>>get_param(gcs, 'filename')
Thanks.. :)

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 24 日
編集済み: Azzi Abdelmalek 2013 年 2 月 24 日
[filename,path]=uigetfile('*.mdl') % path is your file location
file=fullfile(path,filename)
  1 件のコメント
Shameer Parmar
Shameer Parmar 2013 年 2 月 24 日
Thanks Azzi for your reply, but in this case it is asking me to open the model but my case is different. In my case the model is alredy open and I want to know the source directory path for it.
I want to access the value of 'Source File' from 'File' Menu >> Model Properties >> 'Main' Tab >> 'Source File'
DO you know any idea how to do this?
Thanks in advance..

サインインしてコメントする。


Kaustubha Govind
Kaustubha Govind 2013 年 2 月 25 日
You can just run :
which <modelname>
To find the location of the model. Is this what you want?
  1 件のコメント
Shameer Parmar
Shameer Parmar 2013 年 2 月 25 日
Hello Kaustubha,
Thanks for your reply.. The command 'which modelname' is working but only when if the model is present in your matlab setpath. (File Menu >> Setpath). If the model is not available in your matlab Setpath then this command is not working. (This is as per my testing on this command after your reply).
But now I got resolution on my question..
It is get_param(gcs, 'filename')
Thanks for your time and support.. :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVerification, Validation, and Test についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by