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

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function varargout = mirlength(orig,varargin)
Daniel@0 2 % mirlength(x) indicates the temporal length of x.
Daniel@0 3 % Optional argument:
Daniel@0 4 % mirlength(...,'Unit',u) indicates the length unit.
Daniel@0 5 % Possible values:
Daniel@0 6 % u = 'Second': duration in seconds (Default).
Daniel@0 7 % u = 'Sample': length in number of samples.
Daniel@0 8
Daniel@0 9 unit.key = 'Unit';
Daniel@0 10 unit.type = 'String';
Daniel@0 11 unit.choice = {'Second','Sample'};
Daniel@0 12 unit.default = 'Second';
Daniel@0 13 option.unit = unit;
Daniel@0 14
Daniel@0 15 specif.option = option;
Daniel@0 16
Daniel@0 17 varargout = mirfunction(@mirlength,orig,varargin,nargout,specif,@init,@main);
Daniel@0 18
Daniel@0 19
Daniel@0 20 function [x type] = init(x,option)
Daniel@0 21 type = 'mirscalar';
Daniel@0 22
Daniel@0 23
Daniel@0 24 function z = main(a,option,postoption)
Daniel@0 25 if iscell(a)
Daniel@0 26 a = a{1};
Daniel@0 27 end
Daniel@0 28 d = get(a,'Data');
Daniel@0 29 f = get(a,'Sampling');
Daniel@0 30 v = cell(1,length(d));
Daniel@0 31 for h = 1:length(d)
Daniel@0 32 v{h} = cell(1,length(d{h}));
Daniel@0 33 for i = 1:length(d{h})
Daniel@0 34 di = d{h}{i};
Daniel@0 35 v{h}{i} = size(d{h}{i},1);
Daniel@0 36 if strcmp(option.unit,'Second')
Daniel@0 37 v{h}{i} = v{h}{i}/f{h};
Daniel@0 38 end
Daniel@0 39 end
Daniel@0 40 end
Daniel@0 41 z = mirscalar(a,'Data',v,'Title','Temporal length','Unit','s.');