indicator.m

来自「计量工具箱」· M 代码 · 共 29 行

M
29
字号
function ind = indicator(x,setto0)% PURPOSE: converts the matrix x to indicator variables%          associated with the levels in x%---------------------------------------------------% USAGE:     ind = indicator(x,omit)% where:     x = a matrix or vector%         omit = column # to be omitted in return matrix%---------------------------------------------------% RETURNS:%        ind = levels rounded down to integers% --------------------------------------------------% SEE ALSO: levels, tally%---------------------------------------------------% Gordon K Smyth, 22 Jan 90, 29 Jul 97% gks@maths.uq.edu.au% Department of Mathematics, Unversity of Queensland, Q 4072, Australia% http://www.maths.uq.edu.au/~gks/% documentation modified by J.P. LeSage 1/98x=floor(x(:));xmin=min(x); xmax=max(x); xrange=xmax-xmin;ind=( x*ones(1,xrange+1) )==( ones(size(x))*(xmin:xmax) );ind=ind(:,any(ind));if nargin>1   ind(:,setto0)=[];end;

⌨️ 快捷键说明

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