Daniel@0: function varargout = mirlength(orig,varargin) Daniel@0: % mirlength(x) indicates the temporal length of x. Daniel@0: % Optional argument: Daniel@0: % mirlength(...,'Unit',u) indicates the length unit. Daniel@0: % Possible values: Daniel@0: % u = 'Second': duration in seconds (Default). Daniel@0: % u = 'Sample': length in number of samples. Daniel@0: Daniel@0: unit.key = 'Unit'; Daniel@0: unit.type = 'String'; Daniel@0: unit.choice = {'Second','Sample'}; Daniel@0: unit.default = 'Second'; Daniel@0: option.unit = unit; Daniel@0: Daniel@0: specif.option = option; Daniel@0: Daniel@0: varargout = mirfunction(@mirlength,orig,varargin,nargout,specif,@init,@main); Daniel@0: Daniel@0: Daniel@0: function [x type] = init(x,option) Daniel@0: type = 'mirscalar'; Daniel@0: Daniel@0: Daniel@0: function z = main(a,option,postoption) Daniel@0: if iscell(a) Daniel@0: a = a{1}; Daniel@0: end Daniel@0: d = get(a,'Data'); Daniel@0: f = get(a,'Sampling'); Daniel@0: v = cell(1,length(d)); Daniel@0: for h = 1:length(d) Daniel@0: v{h} = cell(1,length(d{h})); Daniel@0: for i = 1:length(d{h}) Daniel@0: di = d{h}{i}; Daniel@0: v{h}{i} = size(d{h}{i},1); Daniel@0: if strcmp(option.unit,'Second') Daniel@0: v{h}{i} = v{h}{i}/f{h}; Daniel@0: end Daniel@0: end Daniel@0: end Daniel@0: z = mirscalar(a,'Data',v,'Title','Temporal length','Unit','s.');