# VMT_SelectFiles

## PURPOSE

Prompts the user to select preprocessed transect files output by

## SYNOPSIS

function [zPathName,zFileName,zf] = VMT_SelectFiles;

## DESCRIPTION

     Prompts the user to select preprocessed transect files output by
     VMT_ReadFiles.

     (adapted from code by J. Czuba)

     P.R. Jackson, USGS, 12-11-08
     Last modified: 3/21/2013
     Frank L. Engel, USGS IL WSC

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- VMT_PlotXSCont Plots contours for the variable 'var' within the mean cross section given
- VMT_PlotXSContMultiPlot Currently not implemented

## SOURCE CODE

    0001 function [zPathName,zFileName,zf] = VMT_SelectFiles;
    0002 % Prompts the user to select preprocessed transect files output by
    0003 % VMT_ReadFiles.
    0004 %
    0005 % (adapted from code by J. Czuba)
    0006 %
    0007 % P.R. Jackson, USGS, 12-11-08
    0008 % Last modified: 3/21/2013
    0009 % Frank L. Engel, USGS IL WSC
    0010
    0011
    0012 %% Load the files
    0013
    0014 % Prompt user for directory containing files
    0015 defaultpath = 'C:\';
    0016 matpath = [];
    0017 if 0 %exist('VMT\LastDir.mat','file') == 2
    0018     load('VMT\LastDir.mat');
    0019     if exist(matpath,'dir') == 7
    0020         matpath = uigetdir(matpath,'Select the Directory Containing Processed Data Files (*.mat)');
    0021     else
    0022         matpath = uigetdir(defaultpath,'Select the Directory Containing Processed Data Files (*.mat)');
    0023     end
    0024 else
    0025     matpath = uigetdir(defaultpath,'Select the Directory Containing Processed Data Files (*.mat)');
    0026 end
    0027 zPathName = matpath;
    0028 Files = dir(zPathName);
    0029 allFiles = {Files.name};
    0030 filefind=strfind(allFiles,'.mat')';
    0031 filesidx=nan(size(filefind,1),1);
    0032 for i=1:size(filefind,1)
    0033     filesidx(i,1)=size(filefind{i},1);
    0034 end
    0035 filesidx=find(filesidx>0);
    0036 files=allFiles(filesidx);
    0037
    0038 if isempty(files)
    0039     errordlg(['No *.MAT files found in ' matpath '.  Ensure you have chosen the correct directory and VMT processed files are present.']);
    0040 end
    0041
    0042 % Allow user to select which files are to be processed
    0043 selection = listdlg('ListSize',[300 300],'ListString', files,'Name','Select Data Files');
    0044 zFileName = files(selection);
    0045
    0046 % Determine number of files to be processed
    0047 if  isa(zFileName,'cell')
    0048     zf=size(zFileName,2);
    0049     zFileName = sort(zFileName);
    0050 else
    0051     zf=1;
    0052     zFileName={zFileName}
    0053 end
    0054
    0055 %% Save the path
    0056 % if exist('LastDir.mat','file') == 2
    0057     % save('LastDir.mat','matpath','-append')
    0058 % else
    0059     % save('LastDir.mat','matpath')
    0060 % end