So, I have a question about choosing the MATLAB directory. I need to use a GUI to select a directory, but the problem is that the uigetdir interface is terrible. If I call like this:
blah = uigetfile('C:\...\T2 Measurements');
Here is what he shows me:

As you can see, this is terrible. There, a ton of extraneous information about the location of the file in the file system and related information is under the palette. Ideally, I would like to indicate that the uigetdir function uses the uigetfile GUI or simply passes an argument to the uiget file telling it that I am looking for a directory and not a single file, because it looks like the uigetfile GUI looks like:

But, of course, for this you need to select a file, not a directory. The directories are obviously not open, so I suppose I could just pick a random random file in a folder, and I can get the path name, but is there a better way to do this? In another application, I could imagine that my โselect file in folderโ method would not work.
Update
I made some very minor adjustments to Andrew Janke code to make it accept the same arguments as uigetdir (). Here is what I came up with:
function [pathname] = uigetdir2(start_path, dialog_title) % Pick a directory with the Java widgets instead of uigetdir import javax.swing.JFileChooser; if nargin == 0 || start_path == '' || start_path == 0 % Allow a null argument. start_path = pwd; end jchooser = javaObjectEDT('javax.swing.JFileChooser', start_path); jchooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if nargin > 1 jchooser.setDialogTitle(dialog_title); end status = jchooser.showOpenDialog([]); if status == JFileChooser.APPROVE_OPTION jFile = jchooser.getSelectedFile(); pathname = char(jFile.getPath()); elseif status == JFileChooser.CANCEL_OPTION pathname = []; else error('Error occured while picking file.'); end
source share