MATLAB Answers


Potential error when compiling a folder path inside a GUI

Asked by Edison
on 24 Jul 2018
Latest activity Commented on by Edison
on 24 Jul 2018
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?


Sign in to comment.

1 Answer

Answer by Abhishek Gupta on 24 Jul 2018
 Accepted Answer

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


The data is constant for every user. What do you mean by relative path?
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);
data = xlsread(romfilename);
Thanks. It works now

Sign in to comment.