-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseVariableInputs.m
68 lines (63 loc) · 1.99 KB
/
parseVariableInputs.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
function prop = parseVariableInputs(arguments)
%% **********************************************************************
%
% function prop = parseVariableInputs(varargin)
%
% usage: prop = parseVariableInputs({'MYPARAM1 = 2';'MYPARAM2 =
% 4'},'mySpecialFilenameWithoutExtension','My general comment');
%
% Autor: Sebastian Schmitter
% Date: Sept. 2011
%
%
% INPUT: [unit]
% -----------------------------------------------------------------------
% first parameter:
% the varargin-parameters from any functions in cell format
% e.g. { 'BWTP = 8';...
% 'ISHANNING = true';...
% 'DURATION = 1024E-6';...
% 'THICKNESS = 5E-3'}
%
% second parameter:
% filename for saving etc.; will be stored in prop.FILENAME
%
% third parameter:
% arbitrary comment; will be stored in prop.COMMENT
%
% OUTPUT:
% -----------------------------------------------------------------------
% properties struct, e.g.
%
% prop.BWTP
% prop.ISHANNING
% etc.
%
%% **********************************************************************
optargin = size(arguments,2);
%first check wheater prop is a struct or a cell
if(optargin > 0)
if(iscell(arguments))
z = arguments{1,1};
if(isstruct(z))
prop = z;
else
for lL=1:length(arguments{1,1})
eval(['prop.',char(arguments{1,1}(lL)),';']);
end
end
else %if iscell
%otherwise it is assumed that inprop is a struct
error('varargin must have cell format');
end
if(optargin >1)
%second input parameter
prop.FILENAME = char(arguments{1,2});
end
if(optargin >2)
prop.COMMENT = char(arguments{1,3});
end
else
prop = struct;
end %if optargin
end