-
Notifications
You must be signed in to change notification settings - Fork 0
/
SNOMchangeFilenameAvsP.m
47 lines (41 loc) · 1.43 KB
/
SNOMchangeFilenameAvsP.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
function [newfilename] = SNOMchangeFilenameAvsP(fileName,meastype)
% change the file name to read a different harmonics
% dataTypeBoolean is 1 if type is Amplitude and 0 if type if Phase or Z
% indx = regexp(fileName,'.gsf');
% input parsing ----------------------------------
p = inputParser;
validfileName = @(x) ischar(x);
validmeasType = @(x) ischar(x) && (length(x) == 1) && ((x == 'P') || (x == 'A'));
addRequired(p,'fileName',validfileName);
addRequired(p,'meastype',validmeasType);
parse(p,fileName,meastype)
%-------------------------------------------------
%for dump file - OLD snom
if isempty(regexp(fileName,'.gsf')) == 1
indx = regexp(fileName,'.dump');
Type = fileName(indx-8:indx-1);
end
%for gsf file - NEW snom
if ~isempty(regexp(fileName,'.gsf')) == 1
indx = regexp(fileName,'.gsf');
if strcmp(fileName(indx-3:indx-1),'raw') == 1
Type = fileName(indx-8:indx-4);
if strcmp(Type(1),'-') == 1
Type = fileName(indx-10:indx-4);
end
if ~isempty(regexp(Type,' Z')) == 1
Type = fileName(indx-6:indx-1);
elseif ~isempty(regexp(Type,'-Z')) == 1
Type = fileName(indx-8:indx-1);
end
else
Type = fileName(indx-4:indx-1);
if strcmp(Type(1),'-') == 1
Type = fileName(indx-5:indx-1);
else
end
end
idx = regexp(fileName,Type);
newfilename = fileName;
newfilename(idx+3) = meastype;
end