trimstd.m 1.22 KB
Newer Older
Allan Campopiano's avatar
Allan Campopiano committed
1
2
function out=trimstd(data,percent)

3
4
disp('WARNING: This function is DEPRECATED and not supported anymore. Use ve_trimstd.m instead.');

Allan Campopiano's avatar
Allan Campopiano committed
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
47
48
49
50
51
52
53
54
if percent<1;
    disp('multiplying percent input by 100...');
    percent=percent*100;
end

npnts=length(data);
nppnts=round(npnts*(percent/100)/2);
srtdata=sort(data);

%Windsorize...
srtdata(1:nppnts)=srtdata(nppnts+1);
srtdata(npnts-(nppnts+1):end)=srtdata(npnts-(nppnts+1)-1);
out=std(srtdata);

%out=std(srtdata(nppnts+1:npnts-(nppnts+1)));

            
            
            
            
%switch dim
%    case 1
%        
%        for i=1:size(data,3);
%            
%            npnts=size(data,2);
%            nppnts=round(npnts*(percent/100));
%            srtdata=sort(data(:,:,i),2);
%            
%            out(:,:,i)=std(srtdata(nppnts+1:npnts-(nppnts+1),:),[],dim);
%        
%        end
%        
%    case 2
%
%        for i=1:size(data,3);
%            size(data(:,:,i))
%
%            npnts=size(data,1);
%            nppnts=round(npnts*(percent/100));
%            srtdata=sort(data(:,:,i),1);
%            size(srtdata)
%            nppnts+1
%            npnts-(nppnts+1)
%            out(:,:,i)=std(srtdata(:,nppnts+1:npnts-(nppnts+1)),[],dim);
%
%        end
%
%end
        
55