Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the starting directory (using uigetfile in Matlab) to 'Computer'?

I made a Matlab GUI. I would like to set the dialog box for input file to be by default set to 'Computer' directory. I know how to change the default path ([FileName PathName] = uigetfile('D:\Applications\Matlab6p5\work\*.m;*.mdl;*.mat','MATLAB Files');), but I don't know what is the name of the path in case of 'Computer' (directory where all server and local disc names are listed). Any suggestions?

like image 252
user3410021 Avatar asked Mar 12 '14 10:03

user3410021


People also ask

How do you call a directory in MATLAB?

In the Current Folder browser, right-click any MATLAB Drive file or folder and select MATLAB Drive > Go to MATLAB Drive Online.... To open the Current Folder browser if it is not visible, go to the Home tab, and in the Environment section, click Layout. Then, under Show, select Current Folder.

How do I use Uigetfile?

file = uigetfile opens a modal dialog box that lists files in the current folder. It enables a user to select or enter the name of a file. If the file exists and is valid, uigetfile returns the file name when the user clicks Open. If the user clicks Cancel or the window close button (X), uigetfile returns 0 .

How do I find the directory path in MATLAB?

Run the path command to view all the folders on the MATLAB search path. Alternatively, use the Set Path dialog box to view the entire MATLAB search path. On the Home tab, in the Environment section, click Set Path. The Set Path dialog box opens, listing all folders on the search path.


1 Answers

  1. Create a directory My Computer.{20d04fe0-3aea-1069-a2d8-08002b30309d} that links to the node "My computer" (see this answer on SU)- you can do the same with other "special folders" - see e.g. the comment by @thewaywewalk.

  2. Use this directory as the start path for uigetfile.

Thus:

tmpLinkToMyComputer = fullfile(tempDir,'MyComputer.{20d04fe0-3aea-1069-a2d8-08002b30309d}');
mkdir(tmpLinkToMyComputer);
uigetfile(fullfile(tmpLinkToMyComputer,'*.m;*.mdl;*.mat'),'MATLAB Files')
like image 193
Jonas Avatar answered Oct 10 '22 16:10

Jonas