Do you need to set "Set Path" when creating a Standalone Desktop Application (GUI)?
이전 댓글 표시
I know this is a vague question, so I'll clarify. I have a GUI that uses "uigetfile" to let the user select a data file to import. The GUI uses the data from the file to create a time table. It works perfectly, however I tried testing it out on my friends computer (just to see how it worked on a Windows laptop) and when I tried importing the file the GUI said it could not find it. This was because I had not set the path for the location of the data (which folder it was in) so MATLAB did not know where to look for the file. I shared the GUI directly to his computer, so I was able to pull up MATLAB command window and set the path which fixed the problem. BUT, in the future I would like to compile the App to create a "Standalone Desktop Application" so that someone without MATLAB could use my App. Which brings me back to my original question, if I were to create a "Standalone Desktop Application" how would the application know were to look for the data files? Would it do what it did on my friends computer and say it didn't exist OR does a desktop application have more versatility and not need a path to be set?? Any information would be great, thanks!!
댓글 수: 5
Bruno Luong
2020년 7월 24일
uigetfile returns the PATH and the FILENAME or 0 if user cancel the file browsing. It's never said any error AFAIK. If you get an error, than it's down of the stream (where you read/load it). You probably use a wrong path and not the one returned by UIGETFILE.
Forrest Ward
2020년 7월 24일
Forrest Ward
2020년 7월 24일
Bruno Luong
2020년 7월 24일
편집: Bruno Luong
2020년 7월 24일
You have to use both Path and Filename. The Path returned is not without purspose.
If you use only Filename MATLAB looks in the default path, and as you have already figure out the default path is not well defined in standalone app (it's somewhere where the encrypted source code is expanded, and usually not the place where the file browed is located).
[file, path] = uigetfile();
if ischar(file)
T = readtable([path, file]);
else
% thow an error
end
Forrest Ward
2020년 7월 24일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!