MATLAB Answers

Do you need to set "Set Path" when creating a Standalone Desktop Application (GUI)?

1 view (last 30 days)
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 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jul 2020
When you use uigetfile, you should use both return parameters:
[filename, filedir] = uigetfile('appropriate parameters here');
if isnumeric(filename)
return; %user canceled
end
fullname = fullfile(filedir, filename);
Now access the file according to fullname
  3 Comments
Walter Roberson
Walter Roberson on 24 Jul 2020
uigetfile can return:
  • numeric, if the user canceled
  • cell array of character vectors, if multiselect is on and the user selected multiple items
  • character vector, if multiselect is off or if it is on but the user only selected one item

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!