Commit d5c8c58b authored by Mike Cichonski's avatar Mike Cichonski
Browse files

ve_trimmean fix for both dimensions

parent bb99a882
......@@ -11,8 +11,13 @@ function trm_m = ve_trimmean(data,ptrim,dim)
%
% trm_m = mean(data_srt(ntrim+1:ntotal-ntrim,:,:));
if dim > 2;
disp ('ERROR: dim must be 1 or 2.');
return
end
if nargin < 3;
dim = 1; % by default, trim rows
dim = 1;
end
if ptrim >= 1;
......@@ -21,18 +26,19 @@ end
ptrim = ptrim/2;
if dim==1; % if we are trimming rows
ntotal = size(data,2);
else % if we are trimming columns
if dim==1;
ntotal = size(data,1);
else
ntotal = size(data,2);
end
ntrim = round(ntotal*ptrim);
data_srt = sort(data);
%Take 1/2 of the requested amount off the top and off the bottom
if dim==1; % if we are trimming rows
trm_m = mean(data_srt(1:size(data_srt,1),ntrim+1:ntotal-ntrim));
else % if we are trimming columns
trm_m = mean(data_srt(ntrim+1:ntotal-ntrim,1:size(data_srt,2)));
if dim==1;
data_srt = sort(data,1);
trm_m = mean(data_srt(ntrim+1:ntotal-ntrim,1:size(data_srt,2)),1);
else
data_srt = sort(data,2);
trm_m = mean(data_srt(1:size(data_srt,1),ntrim+1:ntotal-ntrim),2);
end
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment