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