cellmedian.m
来自「轨迹聚类工具箱及其相关说明和文章(台风路径分类等)。如有问题可与wyljess@」· M 代码 · 共 40 行
M
40 行
function mn = cellmedian(x)
%CELLMEDIAN Calculate median of each cell
% X = CELLMEDIAN(X)
% Scott J Gaffney 11 September 2001
% Department of Information and Computer Science
% University of California, Irvine.
PROGNAME = 'cellmedian';
if (~nargin)
help(PROGNAME);
return;
end
sz = size(x);
if (sz(1)~=1 & sz(2)~=1)
error([PROGNAME, 'only supports vector-sized cell arrays']);
end
% set the size of the output array
mn=[];
a = nan;
for i=1:length(x)
if (~isempty(x{i}))
mn = a(ones(length(x),size(x{i},2))); % set to NaNs
break;
end
end
if (isempty(mn)) % if empty then just return
return;
end
% otherwise, calculate the means
for i=1:length(x)
if (~isempty(x{i}))
mn(i,:) = median(x{i},1);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?