Potential error when compiling a folder path inside a GUI

조회 수: 1 (최근 30일)
Edison
Edison 2018년 7월 24일
댓글: Edison 2018년 7월 24일
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일
it has two ways:
1. either compile the .exe with the data in the folder 2. or ask the path input during compilation
  댓글 수: 6
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개)

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by