-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcarrayFunc.m
46 lines (40 loc) · 1.01 KB
/
mcarrayFunc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
function dout = mcarrayFunc(d,f,varargin)
% Wrapper for applying native Mocap Toolbox functions to mcarrays
% dout = mcarrayFunc(data,f,varargin)
%
% f: string, name of the function, followed by all arguments to the mocap
% toolbox function.
%
% Examples:
%
% d2 = mcarrayFunc(data,'mcnorm')
% d2 = mcarrayFunc(data,'mctrim',2,7)
% d2 = mcarrayFunc(data,'mctrim',25,700,'frame')
% d2 = mcarrayFunc(data,'mctimeder',2)
% d2 = mcarrayFunc(data,'mcmean')
%
% By Kristian Nymoen, RITMO/University of Oslo, 2019
%
fh = str2func(f);
x = varargin;
if ~isempty(d)
if nargout(fh)
switch class(fh(d(1),x{:}))
case 'struct'
for i = 1:length(d)
dout(i) = fh(d(i),x{:});
end
otherwise
for i = 1:length(d)
dout{i} = fh(d(i),x{:});
end
end
else
for i = 1:length(d)
fh(d(i),x{:});
end
end
else
dout = d; %if input is empty the output input
end
end