dixon.m

来自「该文件主要包括了matlab的一些主要应用例程!对学习matlab很有帮助」· M 代码 · 共 44 行

M
44
字号
function d = dixon( x, h )
%dixon        to find a outlying observation in 
%             normal sample
%             using dixon's criterion
%
%x            observation vector, the size must be
%             between 3 and 30.
%
%h=0          if a low observation has been suspected
%             outlying
%h=1          if a top observation has been suspected
%             outlying
%
%             by SHI DAOJI
x = sort ( x );
n = length ( x );
if n >= 31 | n <= 2
   n
      fprintf('Warning: size of sample must be between 3 and 30'); 
else
if h==0
   if n <= 7
         d = ( x ( 2 ) - x ( 1 ) ) / ( x ( n ) - x ( 1 ) );
      elseif n <= 10
         d = ( x ( 2 ) - x ( 1 ) ) / ( x ( n-1 ) - x ( 1 ) );
      elseif n <= 13
         d = ( x ( 3 ) - x ( 1 ) ) / ( x ( n-1 ) - x ( 1 ) );
      elseif n <= 30   
         d = ( x ( 3 ) - x ( 1 ) ) / ( x ( n-2 ) - x ( 1 ) );
      else n >= 31
         print 'warning:'
      end
elseif h==1
       if n <= 7
         d = ( x ( n ) - x ( n-1 ) ) / ( x ( n ) - x ( 1 ) );
      elseif n <= 10
         d = ( x ( n ) - x ( n-1 ) ) / ( x ( n ) - x ( 2 ) );
      elseif n <= 13
         d = ( x ( n ) - x ( n-2 ) ) / ( x ( n ) - x ( 2 ) );
      else n <= 30   
         d = ( x ( n ) - x ( n-2 ) ) / ( x ( n ) - x ( 3 ) );
      end
   end
   end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?