How to run .m file automatically without path?

Dear all,
I have .m file for starting up program. I always have to put (write) the path this .m file. For example: run C:/Program Files/.../file.m. I would like to automatized this action for any PC, without using file path. Is this possible in Matlab?
Thank you for your answers.

 採用された回答

Guillaume
Guillaume 2017 年 3 月 9 日

1 投票

If you don't specify the path to the file, it will have to be in one of the folders on the matlab search path for it to be found. See this page for the folders that are in the search path.

4 件のコメント

Veronika
Veronika 2017 年 3 月 10 日
Okay, concretely I have this path for startup program Eidors:
run C:/Users/ced0005/eidors-v3.8-ng/eidors/startup.m
And I would like to automatized this link of code. How can I do it? Thank you.
Guillaume
Guillaume 2017 年 3 月 10 日
If the folder C:/Users/ced0005/eidors-v3.8-ng/eidors/ is on the matlab search path your startup file will be executed automatically.
If it's not, you have several options as detailed in the page I linked:
  • Permanently change the user home folder with userpath, so
userpath('C:/Users/ced0005/eidors-v3.8-ng/eidors/');
set MATLABPATH="C:/Users/ced0005/eidors-v3.8-ng/eidors/"
Veronika
Veronika 2017 年 3 月 10 日
Okay, but will it works on other computers, where the program eidors has a different path?
Guillaume
Guillaume 2017 年 3 月 13 日
Well, it all depends how you get that program onto other computers. If you use an installer, then either that installer needs to add the folder where it's put to the matlab path, or it needs to put the file(s) in a folder already on the matlab path.
If you copy the program manually, then it's up to you to do the same.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSearch Path についてさらに検索

質問済み:

2017 年 3 月 9 日

コメント済み:

2017 年 3 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by