Potential error when compiling a folder path inside a GUI

Recently i have programmed a functional GUI, but in order to work it needs to change directory and use the information from an specified path folder. Now i need to turn this into an executable using the Compiler. I fear the code will not work since the path directs to a folder within the PC and the executable must run in other computers. Is there a way to include this foreign folder when compiling the GUI?

 採用された回答

Abhishek Gupta
Abhishek Gupta 2018 年 7 月 24 日

0 投票

it has two ways:
1. either compile the .exe with the data in the folder 2. or ask the path input during compilation

6 件のコメント

Edison
Edison 2018 年 7 月 24 日
How do you ask the path during compilation?
Abhishek Gupta
Abhishek Gupta 2018 年 7 月 24 日
I meant specifically by asking in execution of .exe file at other end. use pop up display for asking to load files by using 'uigetdir'
Walter Roberson
Walter Roberson 2018 年 7 月 24 日
Is the data to be considered constant, the same data for every user? If so then move the data to a subdirectory of the place the source code is, and use relative paths, possibly telling MATLAB compiler to add the directory.
If the data is not to be considered constant, if it is to be alterable by the user, then you need a way of figuring out where the data is. For example you could require that it be in a fixed location relative to the executing user's home directory, or you could prompt the user to enter the location.
Edison
Edison 2018 年 7 月 24 日
The data is constant for every user. What do you mean by relative path?
Walter Roberson
Walter Roberson 2018 年 7 月 24 日
So instead of accessing (for example)
data = xlsread('C:\Users\Edison\StarFire\TrainedData\Romulus\physcons.xlsx');
you would first move the file to be relative to the directory you are building the project in, making it something like,
data = xlsread('TrainedData\Romulus\physcons.xlsx');
and then you would convert that to something like,
romfilename = 'TrainedData\Romulus\physcons.xlsx';
if isdeployed
romfilename = fullfile(ctfroot(), romfilename);
end
data = xlsread(romfilename);
Edison
Edison 2018 年 7 月 24 日
Thanks. It works now

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

その他の回答 (0 件)

カテゴリ

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

質問済み:

2018 年 7 月 24 日

コメント済み:

2018 年 7 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by