comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function varargout = mirlength(orig,varargin)
2 % mirlength(x) indicates the temporal length of x.
3 % Optional argument:
4 % mirlength(...,'Unit',u) indicates the length unit.
5 % Possible values:
6 % u = 'Second': duration in seconds (Default).
7 % u = 'Sample': length in number of samples.
8
9 unit.key = 'Unit';
10 unit.type = 'String';
11 unit.choice = {'Second','Sample'};
12 unit.default = 'Second';
13 option.unit = unit;
14
15 specif.option = option;
16
17 varargout = mirfunction(@mirlength,orig,varargin,nargout,specif,@init,@main);
18
19
20 function [x type] = init(x,option)
21 type = 'mirscalar';
22
23
24 function z = main(a,option,postoption)
25 if iscell(a)
26 a = a{1};
27 end
28 d = get(a,'Data');
29 f = get(a,'Sampling');
30 v = cell(1,length(d));
31 for h = 1:length(d)
32 v{h} = cell(1,length(d{h}));
33 for i = 1:length(d{h})
34 di = d{h}{i};
35 v{h}{i} = size(d{h}{i},1);
36 if strcmp(option.unit,'Second')
37 v{h}{i} = v{h}{i}/f{h};
38 end
39 end
40 end
41 z = mirscalar(a,'Data',v,'Title','Temporal length','Unit','s.');