annotate toolboxes/MIRtoolbox1.3.2/MIRToolbox/mirlength.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function varargout = mirlength(orig,varargin)
wolffd@0 2 % mirlength(x) indicates the temporal length of x.
wolffd@0 3 % Optional argument:
wolffd@0 4 % mirlength(...,'Unit',u) indicates the length unit.
wolffd@0 5 % Possible values:
wolffd@0 6 % u = 'Second': duration in seconds (Default).
wolffd@0 7 % u = 'Sample': length in number of samples.
wolffd@0 8
wolffd@0 9 unit.key = 'Unit';
wolffd@0 10 unit.type = 'String';
wolffd@0 11 unit.choice = {'Second','Sample'};
wolffd@0 12 unit.default = 'Second';
wolffd@0 13 option.unit = unit;
wolffd@0 14
wolffd@0 15 specif.option = option;
wolffd@0 16
wolffd@0 17 varargout = mirfunction(@mirlength,orig,varargin,nargout,specif,@init,@main);
wolffd@0 18
wolffd@0 19
wolffd@0 20 function [x type] = init(x,option)
wolffd@0 21 type = 'mirscalar';
wolffd@0 22
wolffd@0 23
wolffd@0 24 function z = main(a,option,postoption)
wolffd@0 25 if iscell(a)
wolffd@0 26 a = a{1};
wolffd@0 27 end
wolffd@0 28 d = get(a,'Data');
wolffd@0 29 f = get(a,'Sampling');
wolffd@0 30 v = cell(1,length(d));
wolffd@0 31 for h = 1:length(d)
wolffd@0 32 v{h} = cell(1,length(d{h}));
wolffd@0 33 for i = 1:length(d{h})
wolffd@0 34 di = d{h}{i};
wolffd@0 35 v{h}{i} = size(d{h}{i},1);
wolffd@0 36 if strcmp(option.unit,'Second')
wolffd@0 37 v{h}{i} = v{h}{i}/f{h};
wolffd@0 38 end
wolffd@0 39 end
wolffd@0 40 end
wolffd@0 41 z = mirscalar(a,'Data',v,'Title','Temporal length','Unit','s.');