📄 percentiles.m
字号:
function [percts, s]=percentiles(x,dim,p)
% % percentiles: Calculates the percentiles of an array
% %
% % Syntax: [percts]=percentiles(x,dim,p);
% %
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% % Description
% %
% % [percts]=percentiles(x, dim, p);
% %
% % This program uses Duane Hanselman's allstats and just returns the
% % percentiles. It would be quite difficult to write a better function
% % than what Duane has already produced.
% %
% % This recreation of his program makes it easier to get the
% % percentiles into an array for futher processing.
% %
% % Returns the percentiles of input array x along the dimension dim
% % given the input percentiles p. p is the percentiles from 0 to 100.
% %
% % [percts, s]=percentiles(x, dim, p);
% % Returns the structure s from allststs with nearly every ststistic
% % commonly used. See allstats for a description of the output structure
% % s.
% %
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% % List of Dependent Subprograms for
% % percentiles
% %
% % Program Name Author FEX ID#
% % 1) allstats Duane Hanselman NA
% %
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% % percentiles written by Edward Zechmann
% %
% % date 18 July 2008
% %
% % modified 10 September 2008
% %
% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% % Please Feel Free to Modify This Program
% %
% % See Also: allstats
% %
s=allstats(x, dim, 0, p);
pfn=reshape(sprintf('p%02d',1:length(p)),3,[])'; % field name char array
for e1=1:length(p);
if e1 == 1
percts=zeros(length(s.(pfn(e1,:))), length(p));
end
[percts(:, e1)]=s.(pfn(e1,:));
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -