-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuiimport.m
77 lines (68 loc) · 2.65 KB
/
uiimport.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
function uiimport(filepath)
% UIIMPORT overloaded for custom files.
%
% Executed when file is dragged to the workspace, will call custom import
% routines for recognized files, and import unrecognized files with
% standard uiimport. A directory can also be dragged into the workspace,
% in which case all the recognized file types contained in the first level
% will be imported and unrecognized file types ignored.
%
% T Hennen 2013
%Define DMS types
DMStypes = {'.VHD','.VRD','.VDD'};
%Define PK types
PKtypes = {'.mdd','.svd','.svp'};
[dirpath, filename, extension] = fileparts(filepath);
%If the dragged file has an extension (not a folder)
if ~isempty(extension)
Files(1).name = [filename extension];
% Determine if file extension matches a DMS type
isDMS = any(strcmpi(DMStypes,extension));
% or PK type
isPK = any(strcmpi(PKtypes,extension));
% If other file type, run uiimport as usual
if ~isDMS && ~isPK
presentPWD = pwd;
cd([matlabroot '\toolbox\matlab\codetools\']);
uiimport(filepath);
cd(presentPWD);
end
else
% User dragged in a folder, search for and import DMS and PK types in that folder,
% ignoring other types
Files = dir(filepath);
dirpath = [dirpath '\' filename];
end
for i=1:length(Files)
[a, filename, extension] = fileparts(Files(i).name);
% Determine if file extension matches a DMS type
isDMS = any(strcmpi(DMStypes,extension));
% or PK type
isPK = any(strcmpi(PKtypes,extension));
if (isDMS)
% All DMS data uses same import function
DMSImport([dirpath '\' Files(i).name]);
elseif (isPK)
% Determine the type of PK data by looking at extension and the end of the file name
if strcmpi(extension,'.mdd')
% If it's a recoil or recoil+dyn file, our only hope of identifying it is to
% find the word recoil in the filename.
if regexpi(filename,'recoil')
% Recoil files end in 0_0
if strcmp(filename(end-2:end),'0_0')
PKImportRecoil([dirpath '\' Files(i).name]);
% Dynamic files end in whatever they please (eg. 0_108, 0_77)
else
PKImportDyn([dirpath '\' Files(i).name]);
end
else
% General PK import for .mdd with no "recoil" in the name
PKImport([dirpath '\' Files(i).name]);
end
elseif strcmpi(extension,'.svd')
PKImportSVD([dirpath '\' Files(i).name]);
elseif strcmpi(extension,'.svp')
PKImportSVP([dirpath '\' Files(i).name]);
end
end
end