


SPLIT split an analysis object into the specified segments.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
DESCRIPTION: SPLIT split an analysis object into the specified segments.
CALL: b = split(a, pl)
INPUTS: a - input analysis object
pl - input parameter list (see below for parameters)
OUTPUTS: b - array of analysis objects
PARAMETERS: <key> <value> <description>
'split_type' 'times' split the ao into time segments
'frequencies' split the ao into frequencies segments
'samples' split the ao into sample segments
'chunks' split the ao into chunks
'duration' select a duration of a tsdata
Necessary for the individual split types:
<split type> <key> <description>
'times' 'times' an array of start/stop times to split by
'frequencies' 'frequencies' an array of start/stop frequencies to split by
'samples' 'samples' an array of start/stop samples to split by
'chunks' 'N' split into N contiguous pieces
'interval' 'start_time', 'stop_time'
- start/stop time can be either a string or a time
object (if a string, 'format_str' must be
specified or specify the strings in UTC time format)
'interval' 'start_time', 'duration'
- start time and the duration can be either a string
or a time object (if a string, 'format_str' must be
specified or specify the strings in UTC time format)
'interval' 'timespan'
- the start/end time are specified in the time span
object.
The UTC time format is: 'yyyy-mm-dd HH:MM:SS'
If more than one splitting method is specified, the priority
goes like the list above.
The time vector in the output AO retains the original
time values (i.e. it doesn't start from zero).
The splitting is done as s<=t<e.
Arrays of start/stop values should be like: [s1 e1 s2 e2 ....]
EXAMPLES: 1.) Split method by frequency. Get the values from 10-100 Hz
pl = plist('split_type', 'frequencies', ...
'frequencies', [10 100]);
ao_new = split(a1, pl);
2.) Split method by time.
Get the values from 0.0 to 1.0 Seconds AND from 1.0 to 2.5 seconds
pl = plist('split_type', 'times', ...
'times', [0.0 1.0 1.0 2.5]);
ao_new = split(a1, pl);
3.) Split method by samples.
Get the samples from 0 to 50 AND from 150 to 200.
pl = plist('split_type', 'samples', ...
'samples', [0 50 150 200]);
ao_new = split(a1, pl);
4.1) Select an interval with strings
pl = plist('split_type', 'interval', ...
'start_time', '14:00:01', ...
'end_time', '14:00:02', ...
'format_str', 'HH:MM:SS');
ao_new = split(a1, pl);
pl = plist('split_type', 'interval', ...
'start_time', '14:00:01', ...
'duration', '00:00:02', ...
'format_str', 'HH:MM:SS');
ao_new = split(a1, pl);
4.2) Select an interval with time objects
pl = plist('split_type', 'interval', ...
'start_time', time('14:00:01', 'HH:MM:SS'), ...
'end_time', time('2007-10-10 14:00:03'));
ao_new = split(a1, pl);
pl = plist('split_type', 'interval', ...
'start_time', time('14:00:01', 'HH:MM:SS'), ...
'duration', time('00:00:05', 'HH:MM:SS'));
ao_new = split(a1, pl);
4.3) Select an interval with a time span object
pl = plist('split_type', 'interval', ...
'timespan', timespan('14:00:00', '14:00:05', 'HH:MM:SS'));
ao_new = split(a1, pl);
The following call returns a parameter list object that
contains the default parameter values:
>> pl = split(ao, 'Params')
VERSION: $Id: split.m,v 1.29 2008/01/20 15:39:09 mauro Exp $
HISTORY: 02-03-07 M Hewitson
Creation.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


0001 function bo = split(varargin) 0002 % SPLIT split an analysis object into the specified segments. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: SPLIT split an analysis object into the specified segments. 0007 % 0008 % CALL: b = split(a, pl) 0009 % 0010 % INPUTS: a - input analysis object 0011 % pl - input parameter list (see below for parameters) 0012 % 0013 % OUTPUTS: b - array of analysis objects 0014 % 0015 % PARAMETERS: <key> <value> <description> 0016 % 'split_type' 'times' split the ao into time segments 0017 % 'frequencies' split the ao into frequencies segments 0018 % 'samples' split the ao into sample segments 0019 % 'chunks' split the ao into chunks 0020 % 'duration' select a duration of a tsdata 0021 % 0022 % Necessary for the individual split types: 0023 % <split type> <key> <description> 0024 % 'times' 'times' an array of start/stop times to split by 0025 % 'frequencies' 'frequencies' an array of start/stop frequencies to split by 0026 % 'samples' 'samples' an array of start/stop samples to split by 0027 % 'chunks' 'N' split into N contiguous pieces 0028 % 'interval' 'start_time', 'stop_time' 0029 % - start/stop time can be either a string or a time 0030 % object (if a string, 'format_str' must be 0031 % specified or specify the strings in UTC time format) 0032 % 'interval' 'start_time', 'duration' 0033 % - start time and the duration can be either a string 0034 % or a time object (if a string, 'format_str' must be 0035 % specified or specify the strings in UTC time format) 0036 % 'interval' 'timespan' 0037 % - the start/end time are specified in the time span 0038 % object. 0039 % 0040 % The UTC time format is: 'yyyy-mm-dd HH:MM:SS' 0041 % 0042 % If more than one splitting method is specified, the priority 0043 % goes like the list above. 0044 % 0045 % The time vector in the output AO retains the original 0046 % time values (i.e. it doesn't start from zero). 0047 % 0048 % The splitting is done as s<=t<e. 0049 % 0050 % Arrays of start/stop values should be like: [s1 e1 s2 e2 ....] 0051 % 0052 % EXAMPLES: 1.) Split method by frequency. Get the values from 10-100 Hz 0053 % pl = plist('split_type', 'frequencies', ... 0054 % 'frequencies', [10 100]); 0055 % ao_new = split(a1, pl); 0056 % 0057 % 2.) Split method by time. 0058 % Get the values from 0.0 to 1.0 Seconds AND from 1.0 to 2.5 seconds 0059 % pl = plist('split_type', 'times', ... 0060 % 'times', [0.0 1.0 1.0 2.5]); 0061 % ao_new = split(a1, pl); 0062 % 0063 % 3.) Split method by samples. 0064 % Get the samples from 0 to 50 AND from 150 to 200. 0065 % pl = plist('split_type', 'samples', ... 0066 % 'samples', [0 50 150 200]); 0067 % ao_new = split(a1, pl); 0068 % 0069 % 4.1) Select an interval with strings 0070 % pl = plist('split_type', 'interval', ... 0071 % 'start_time', '14:00:01', ... 0072 % 'end_time', '14:00:02', ... 0073 % 'format_str', 'HH:MM:SS'); 0074 % ao_new = split(a1, pl); 0075 % 0076 % pl = plist('split_type', 'interval', ... 0077 % 'start_time', '14:00:01', ... 0078 % 'duration', '00:00:02', ... 0079 % 'format_str', 'HH:MM:SS'); 0080 % ao_new = split(a1, pl); 0081 % 0082 % 4.2) Select an interval with time objects 0083 % pl = plist('split_type', 'interval', ... 0084 % 'start_time', time('14:00:01', 'HH:MM:SS'), ... 0085 % 'end_time', time('2007-10-10 14:00:03')); 0086 % ao_new = split(a1, pl); 0087 % 0088 % pl = plist('split_type', 'interval', ... 0089 % 'start_time', time('14:00:01', 'HH:MM:SS'), ... 0090 % 'duration', time('00:00:05', 'HH:MM:SS')); 0091 % ao_new = split(a1, pl); 0092 % 0093 % 4.3) Select an interval with a time span object 0094 % pl = plist('split_type', 'interval', ... 0095 % 'timespan', timespan('14:00:00', '14:00:05', 'HH:MM:SS')); 0096 % ao_new = split(a1, pl); 0097 % 0098 % The following call returns a parameter list object that 0099 % contains the default parameter values: 0100 % >> pl = split(ao, 'Params') 0101 % 0102 % VERSION: $Id: split.m,v 1.29 2008/01/20 15:39:09 mauro Exp $ 0103 % 0104 % HISTORY: 02-03-07 M Hewitson 0105 % Creation. 0106 % 0107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0108 0109 ALGONAME = 'split'; 0110 VERSION = '$Id: split.m,v 1.29 2008/01/20 15:39:09 mauro Exp $'; 0111 bo = []; 0112 0113 % Check if this is a call for parameters 0114 if nargin == 2 0115 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0116 in = char(varargin{2}); 0117 if strcmp(in, 'Params') 0118 bo = getDefaultPL(); 0119 return 0120 elseif strcmp(in, 'Version') 0121 bo = VERSION; 0122 return 0123 end 0124 end 0125 end 0126 0127 %% Collect input ao's, plist's and ao variable names 0128 in_names = {}; 0129 for ii = 1:nargin 0130 in_names{end+1} = inputname(ii); 0131 0132 if isnumeric(varargin{ii}) 0133 samples = [samples varargin{ii}]; 0134 end 0135 end 0136 0137 [as, pl, invars] = collect_inputs(varargin, in_names); 0138 0139 if ~isempty (pl) 0140 pl = combine(pl); 0141 end 0142 0143 %% go through analysis objects 0144 for j=1:numel(as) 0145 0146 % Unpack parameter list 0147 split_type = find(pl, 'split_type'); 0148 0149 % check old version without the key 'split_type' 0150 if ~isempty(find(pl, 'samples')) 0151 split_type = 'samples'; 0152 elseif ~isempty(find(pl, 'times')) || ... 0153 ~isempty(find(pl, 'frequencies')) 0154 split_type = 'times'; % times is the same to frequencies 0155 end 0156 0157 if isempty(split_type) 0158 error('### please specify the key ''split_type'' in the parameter list'); 0159 end 0160 0161 % look at input data 0162 d = as(j).data; 0163 0164 [x,y] = get_xy_values(as(j).data); 0165 0166 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0167 % splitting by time or frequency % 0168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0169 if strcmpi(split_type, 'times') || strcmpi(split_type, 'frequencies') 0170 0171 times = find(pl, 'times'); 0172 frequencies = find(pl, 'frequencies'); 0173 0174 if ~isempty(times) 0175 disp('* splitting by time...'); 0176 split_x_axis.type = 'times'; 0177 split_x_axis.value = times; 0178 else 0179 disp('* splitting by frequency...'); 0180 split_x_axis.type = 'frequencies'; 0181 split_x_axis.value = frequencies; 0182 end 0183 0184 % examine time list 0185 ntimes = length(split_x_axis.value); 0186 if mod(ntimes, 2) ~= 0 0187 error('### please specify a start and stop for each interval.') 0188 end 0189 0190 % go over each interval now 0191 for i=1:2:ntimes 0192 0193 is = split_x_axis.value(i); 0194 ie = split_x_axis.value(i+1); 0195 0196 idx = find(x>=is & x <ie); 0197 0198 % Make output analysis object 0199 nameStr = sprintf('split(%s)', d.name); 0200 0201 % create new output data 0202 d = set_xy_axis(d, x(idx), y(idx)); 0203 d = set(d, 'name', nameStr); 0204 0205 % create new output history 0206 h = history(ALGONAME, VERSION, plist(param(split_x_axis.type, [is ie])), as(j).hist); 0207 h = set(h, 'invars', invars(j)); 0208 0209 % Set nsecs for tsdata 0210 if isa(d, 'tsdata') 0211 if ~isempty(d.x) 0212 d.nsecs = d.x(end) - d.x(1) + 1/d.fs; 0213 else 0214 d.nsecs = 0; 0215 end 0216 end 0217 0218 % make output analysis object 0219 b = ao(d, h); 0220 0221 % set name 0222 b = setnh(b, 'name', sprintf('split(%s)', invars{j})); 0223 0224 % Add to output array 0225 bo = [bo b]; 0226 0227 end 0228 0229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0230 % splitting by samples % 0231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0232 elseif strcmpi(split_type, 'samples') 0233 0234 disp('* splitting by samples...'); 0235 0236 samples = find(pl, 'samples'); 0237 0238 % examine time list 0239 npairs = length(samples); 0240 if mod(npairs, 2) ~= 0 0241 error('### please specify a start and stop for each interval.') 0242 end 0243 0244 % go over each interval now 0245 for i=1:2:npairs 0246 0247 is = samples(i); 0248 ie = samples(i+1); 0249 0250 % Make output analysis object 0251 nameStr = sprintf('split(%s)', d.name); 0252 0253 % create new output data 0254 x1 = x(is:ie); 0255 y1 = y(is:ie); 0256 d = set_xy_axis(d, x1, y1); 0257 d = set(d, 'name', nameStr); 0258 0259 % create new output history 0260 h = history(ALGONAME, VERSION, plist(param('samples', [is ie])), as(j).hist); 0261 h = set(h, 'invars', invars); 0262 0263 % make output analysis object 0264 b = ao(d, h); 0265 0266 % set name 0267 b = setnh(b, 'name', sprintf('split(%s)', invars{j})); 0268 0269 % Add to output array 0270 bo = [bo b]; 0271 0272 end 0273 0274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0275 % splitting into chunks % 0276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0277 elseif strcmpi(split_type, 'chunks') 0278 0279 N = find(pl, 'N'); 0280 0281 disp(sprintf('* splitting into %d chunks', N)); 0282 error('### I have not been written yet. Please code me up.'); 0283 0284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0285 % splitting into interval % 0286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0287 elseif strcmpi(split_type, 'interval') 0288 0289 %% get values from the parameter list 0290 duration = find(pl, 'duration'); 0291 start_time = find(pl, 'start_time'); 0292 end_time = find(pl, 'end_time'); 0293 format_str = find(pl, 'format_str'); 0294 timespan = find(pl, 'timespan'); 0295 0296 %%%%%%%%%%%%%%%%%%%%%%%% Convert the time object %%%%%%%%%%%%%%%%%%%%%%%% 0297 if ~isempty(start_time) && isa(start_time, 'time') 0298 if ~isempty(format_str) 0299 start_time = set(start_time, 'timeformat', format_str); 0300 else 0301 format_str = char(start_time.timeformat); 0302 end 0303 % format_str = char(start_time.timeformat); 0304 start_time = char(start_time); 0305 end 0306 0307 if ~isempty(end_time) && isa(end_time, 'time') 0308 if ~isempty(format_str) 0309 end_time = set(end_time, 'timeformat', format_str); 0310 else 0311 format_str = char(end_time.timeformat); 0312 end 0313 % format_str = char(end_time.timeformat); 0314 end_time = char(end_time); 0315 end 0316 0317 if ~isempty(duration) && isa(duration, 'time') 0318 if ~isempty(format_str) 0319 duration = set(duration, 'timeformat', format_str); 0320 else 0321 format_str = char(duration.timeformat); 0322 end 0323 % format_str = char(end_time.timeformat); 0324 duration = char(duration); 0325 end 0326 0327 %%%%%%%%%%%%%%%%%%%%% Convert the time span object %%%%%%%%%%%%%%%%%%%%%% 0328 if ~isempty(timespan) 0329 start_time = char(timespan.start); 0330 end_time = char(timespan.end); 0331 format_str = char(timespan.timeformat); 0332 duration = ''; 0333 end 0334 0335 UTC = false; 0336 0337 %% check the input values 0338 if ~isa(as(j).data, 'tsdata') 0339 error ('### the split type: ''duration'' only works with tsdata.') 0340 end 0341 0342 if (isempty(start_time) && ... 0343 (isempty(duration) || isempty(end_time))) 0344 error ('### please specify the key ''start_time'' AND ''end_stime'' OR ''duration'' in the parameter list') 0345 end 0346 0347 if (ischar(start_time) || ... 0348 ischar(end_time) || ... 0349 ischar(duration) ) && ... 0350 isempty(format_str) 0351 %% are the time strings in UTC (yyy-mm-dd HH:MM:SS) 0352 %% then set the format string to the UTC format. 0353 if isUTCformat(start_time) || ... 0354 isUTCformat(end_time) || ... 0355 isUTCformat(duration) 0356 format_str = 'yyyy-mm-dd HH:MM:SS'; 0357 else 0358 error ([char (10) '### please specify the key ''format_str'' for the keys ' ... 0359 '''start_time'', ''end_time'' OR/AND ''duration''']) 0360 end 0361 end 0362 0363 disp('* splitting by interval ...'); 0364 0365 %% convert the start time 0366 if isUTCformat(start_time) 0367 UTC = true; 0368 start_time = time(start_time); 0369 start_time = start_time.utc_epoch_milli/1000; 0370 elseif ischar (start_time) 0371 start_time = getSeconds(start_time, format_str); 0372 end 0373 0374 %% convert the end time 0375 if isUTCformat(end_time) 0376 UTC = true; 0377 end_time = time(end_time); 0378 end_time = end_time.utc_epoch_milli/1000; 0379 elseif ischar (end_time) 0380 end_time = getSeconds(end_time, format_str); 0381 end 0382 0383 %% convert the duration 0384 if ~isempty(end_time) && ~isempty(duration) 0385 warning (['### in the parameter list are both parameter '... 0386 '''end_time'' and ''duration''. Using the parameter ''end_time''']) 0387 elseif ischar(duration) && ~isempty(duration) 0388 duration = getSeconds(duration, format_str); 0389 end 0390 0391 %% get/convert the t0 0392 t0 = as(j).data.t0; 0393 t_unix_time = t0.utc_epoch_milli/1000; 0394 t1 = x(1); 0395 0396 if UTC == true 0397 ts = start_time-t_unix_time+t1; 0398 if ~isempty(end_time) 0399 te = end_time-t_unix_time+t1; 0400 else 0401 te = ts+duration; 0402 end 0403 else 0404 0405 t0_offset = format(t0, format_str); 0406 t0_offset = getSeconds(t0_offset, format_str); 0407 0408 ts = start_time+t1-t0_offset; 0409 if ~isempty(end_time) 0410 te = end_time+t1-t0_offset; 0411 else 0412 te = start_time+duration+t1-t0_offset; 0413 end 0414 end 0415 0416 idx = find(x>=ts & x <te); 0417 0418 % Make output analysis object 0419 nameStr = sprintf('split(%s)', d.name); 0420 0421 % create new output data 0422 d = set_xy_axis(d, x(idx), y(idx)); 0423 d = set(d, 'name', nameStr); 0424 0425 % Set nsecs for tsdata 0426 if isa(d, 'tsdata') 0427 if ~isempty(d.x) 0428 d.nsecs = d.x(end) - d.x(1) + 1/d.fs; 0429 else 0430 d.nsecs = 0; 0431 end 0432 end 0433 0434 % create new output history 0435 h = history(ALGONAME, VERSION, pl, as(j).hist); 0436 h = set(h, 'invars', invars); 0437 0438 % make output analysis object 0439 b = ao(d, h); 0440 0441 % set name 0442 b = setnh(b, 'name', sprintf('split(%s)', invars{j})); 0443 0444 % Add to output array 0445 bo = [bo b]; 0446 0447 0448 else 0449 error('### do not know how to split.') 0450 end 0451 0452 end % for j = 1:numel(as) 0453 0454 % Reshape the ouput to the same size of the input 0455 if numel(bo) == numel(as) 0456 bo = reshape(bo, size(as)); 0457 end 0458 0459 end % split 0460 0461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0462 % 0463 % FUNCTION: getDefaultPL 0464 % 0465 % DESCRIPTION: Returns the default parameter list 0466 % 0467 % HISTORY: 02-03-07 M Hewitson 0468 % Creation. 0469 % 0470 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0471 0472 function plo = getDefaultPL() 0473 0474 disp('* creating default plist...'); 0475 plo = plist(); 0476 plo = append(plo, param('split_type', '')); 0477 plo = append(plo, param('times', [])); 0478 plo = append(plo, param('frequencies', [])); 0479 plo = append(plo, param('samples', [])); 0480 plo = append(plo, param('N', [])); 0481 plo = append(plo, param('duration', '')); 0482 plo = append(plo, param('start_time', '')); 0483 plo = append(plo, param('end_time', '')); 0484 plo = append(plo, param('format_str', '')); 0485 disp('* done.'); 0486 0487 end % getDefaultPL 0488 0489 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0490 % 0491 % FUNCTION: isUTCformat 0492 % 0493 % DESCRIPTION: Check the input to the UTC time format (yyyy-mm-dd- HH:MM:SS) 0494 % 0495 % HISTORY: 11-07-07 Diepholz 0496 % Creation. 0497 % 0498 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0499 0500 function bool = isUTCformat(time_string) 0501 0502 bool = false; 0503 0504 if ischar(time_string) 0505 if regexp(time_string, '\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}') 0506 bool = true; 0507 end 0508 end 0509 0510 end % isUTCformat 0511 0512 0513 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0514 % 0515 % FUNCTION: getSeconds 0516 % 0517 % DESCRIPTION: Returns the seconds for any time format with hours minutes 0518 % ans seconds. 0519 % 0520 % HISTORY: 11-07-07 Diepholz 0521 % Creation. 0522 % 0523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0524 0525 function sec = getSeconds(time_str, format_str) 0526 0527 % The customer use year, month or day to specify the time_str 0528 if regexp(format_str, '[ymd]') 0529 if ~strcmp('yyyy-mm-dd HH:MM:SS', format_str) 0530 error (['### if you want to specify the time without using the UTC time '... 0531 'use only hours(HH) minutes(MM) and seconds(SS)']) 0532 end 0533 end 0534 0535 try 0536 sec = ( datenum(time_str, format_str) - fix(datenum(time_str, format_str)) ) * 86400; 0537 sec = round(sec*1000)/1000; 0538 catch 0539 last_error = lasterror; 0540 if strfind(last_error.identifier, 'datenum') 0541 error ([last_error.message char(10) char(10) ... 0542 'time_str = ''' time_str ''' format string = ''' format_str '''']) 0543 else 0544 error (last_error.message) 0545 end 0546 end 0547 0548 end % getSeconds