1 |
gmaze |
1.1 |
% |
2 |
|
|
% date = dtecco2(X,FORM) |
3 |
|
|
% |
4 |
|
|
% If: |
5 |
|
|
% FORM = 0, translate the stepnum X into a date string (yyyymmddHHMM) |
6 |
|
|
% FORM = 1, translate the date string X (yyyymmddHHMM) into a stepnum |
7 |
|
|
% |
8 |
|
|
% 06/08/29 |
9 |
|
|
% gmaze@mit.edu |
10 |
|
|
% |
11 |
|
|
|
12 |
|
|
function varargout = dtecco2(varargin) |
13 |
|
|
|
14 |
|
|
% Test inputs: |
15 |
|
|
if nargin ~= 2 |
16 |
|
|
help dtecco2.m |
17 |
|
|
error('dtecco2.m : Wrong number of parameters'); |
18 |
|
|
return |
19 |
|
|
end %if |
20 |
|
|
|
21 |
|
|
% Recup inputs: |
22 |
|
|
X = varargin{1}; |
23 |
|
|
FORM = varargin{2}; |
24 |
|
|
|
25 |
|
|
% New tests: |
26 |
|
|
if FORM~=0 & FORM~=1 |
27 |
|
|
help dtecco2.m |
28 |
|
|
error('dtecco2.m : Second argument must be 0 or 1'); |
29 |
|
|
return |
30 |
|
|
elseif FORM == 0 & ~isnumeric(X) |
31 |
|
|
help dtecco2.m |
32 |
|
|
error('dtecco2.m : if 2nd arg is 0, 1st arg must be numeric'); |
33 |
|
|
return |
34 |
|
|
elseif FORM == 1 & isnumeric(X) |
35 |
|
|
help dtecco2.m |
36 |
|
|
error('dtecco2.m : if 2nd arg is 1, 1st arg must be a string'); |
37 |
|
|
return |
38 |
|
|
end |
39 |
|
|
|
40 |
|
|
|
41 |
|
|
% Let's go: |
42 |
|
|
switch FORM |
43 |
|
|
|
44 |
|
|
case 0 |
45 |
|
|
ID = datestr(datenum(1992,1,1)+X*300/60/60/24,'yyyymmddHHMM'); |
46 |
|
|
varargout(1) = {ID}; |
47 |
|
|
|
48 |
|
|
case 1 |
49 |
|
|
ID = 60*60*24/300*( datenum(X,'yyyymmddHHMM') - datenum(1992,1,1) ); |
50 |
|
|
varargout(1) = {ID}; |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
end %switch |