How can I change addpath or change workinf dic in appdesigner/ .exe ?

17 ビュー (過去 30 日間)
Kaustubh hike
Kaustubh hike 2021 年 9 月 3 日
コメント済み: Walter Roberson 2021 年 9 月 6 日
Hi,
WHile running the .exe file, If I use cd or addpath for changing the directory , it failes.
In Matlab app it works but in .exe it failes.
Is there are alternative for changing the working dictonary which runs sucessfully while running executable app?

採用された回答

Walter Roberson
Walter Roberson 2021 年 9 月 3 日
addpath and cd can be seen as requests to change which functions are executed at runtime -- for example cd'ing into a directory that has its own sqrt.m there and expecting that at run-time it would pick up that sqrt() for as long as it is executing in that directory.
But compiled executables need to be built with static paths for .m and related executable objects. If you need to add directories to the path at the beginning of execution just to bring in the hierarchy, then the app building GUI has a place to specify directories to add to the path, or if you are using the command line, you can use mcc -a
So, at execution time, the only thing that is left for cd or addpath to do, is to change the path to find data files. But you should not do that: you should use fully-qualified file names instead.
In short: Don't change the working directory. Build all necessary paths into the executable, and use fully-qualified files instead of relative files.
  4 件のコメント
Kaustubh hike
Kaustubh hike 2021 年 9 月 6 日
@Walter Roberson, Thats very helpful. but what is exactly FILEDIRECTORY ?
Walter Roberson
Walter Roberson 2021 年 9 月 6 日
FILEDIRECTORY is the directory that the files are in. A variable containing the name of the directory that you wanted to cd() to.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by