wolffd@0
|
1 function varargout = mirmode(x,varargin)
|
wolffd@0
|
2 % m = mirmode(a) estimates the mode. A value of 0 indicates a complete
|
wolffd@0
|
3 % incertainty, whereas a positive value indicates a dominance of
|
wolffd@0
|
4 % major mode and a negative value indicates a dominance of minor mode.
|
wolffd@0
|
5 % Optional arguments:
|
wolffd@0
|
6 % mirmode(a,s) specifies a strategy.
|
wolffd@0
|
7 % Possible values for s: 'Sum', 'Best'(default)
|
wolffd@0
|
8
|
wolffd@0
|
9 stra.type = 'String';
|
wolffd@0
|
10 stra.default = 'Best';
|
wolffd@0
|
11 stra.choice = {'Best','Sum'};
|
wolffd@0
|
12 option.stra = stra;
|
wolffd@0
|
13
|
wolffd@0
|
14 specif.option = option;
|
wolffd@0
|
15 specif.defaultframelength = 1;
|
wolffd@0
|
16 specif.defaultframehop = .5;
|
wolffd@0
|
17
|
wolffd@0
|
18 varargout = mirfunction(@mirmode,x,varargin,nargout,specif,@init,@main);
|
wolffd@0
|
19
|
wolffd@0
|
20
|
wolffd@0
|
21 function [x type] = init(x,option)
|
wolffd@0
|
22 if not(isamir(x,'mirkeystrength'))
|
wolffd@0
|
23 x = mirkeystrength(x);
|
wolffd@0
|
24 end
|
wolffd@0
|
25 type = 'mirscalar';
|
wolffd@0
|
26
|
wolffd@0
|
27
|
wolffd@0
|
28 function o = main(s,option,postoption)
|
wolffd@0
|
29 if iscell(s)
|
wolffd@0
|
30 s = s{1};
|
wolffd@0
|
31 end
|
wolffd@0
|
32 m = get(s,'Data');
|
wolffd@0
|
33 if strcmpi(option.stra,'sum')
|
wolffd@0
|
34 v = mircompute(@algosum,m);
|
wolffd@0
|
35 elseif strcmpi(option.stra,'best')
|
wolffd@0
|
36 v = mircompute(@algobest,m);
|
wolffd@0
|
37 end
|
wolffd@0
|
38 b = mirscalar(s,'Data',v,'Title','Mode');
|
wolffd@0
|
39 o = {b,s};
|
wolffd@0
|
40
|
wolffd@0
|
41
|
wolffd@0
|
42 function v = algosum(m)
|
wolffd@0
|
43 v = sum(abs(m(:,:,:,1))) - sum(abs(m(:,:,:,2)));
|
wolffd@0
|
44
|
wolffd@0
|
45
|
wolffd@0
|
46 function v = algobest(m)
|
wolffd@0
|
47 v = max(m(:,:,:,1)) - max(m(:,:,:,2)); |