Commit 8c435888 authored by Mike Cichonski's avatar Mike Cichonski
Browse files

modified ve_trimmean to work on both rows and columns

parent 75452861
function trm_m = ve_trimmean(data,ptrim)
function trm_m = ve_trimmean(data,ptrim,dim)
%
% if ptrim > 1;
% ptrim = ptrim/100;
......@@ -12,6 +11,9 @@ function trm_m = ve_trimmean(data,ptrim)
%
% trm_m = mean(data_srt(ntrim+1:ntotal-ntrim,:,:));
if nargin < 3;
dim = 1; % by default, trim rows
end
if ptrim >= 1;
ptrim = ptrim/100;
......@@ -19,10 +21,18 @@ end
ptrim = ptrim/2;
ntotal = length(data);
ntrim = round(ntotal*ptrim);
if dim==1; % if we are trimming rows
ntotal = size(data,2);
else % if we are trimming columns
ntotal = size(data,1);
end
ntrim = round(ntotal*ptrim);
data_srt = sort(data);
%Take 1/2 of the requested amount off the top and off the bottom
trm_m = mean(data_srt(ntrim+1:ntotal-ntrim,1:size(data_srt,2)));
\ No newline at end of file
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)));
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