Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


idummy.m

Go to the documentation of this file.
00001 function d = idummy(x, method)
00002 %DUMMY  Creates a matrix of dummy variables for a discrete variable
00003 %   D=IDUMMY(X,METHOD) creates an array D of dummy variables for the
00004 %   grouping variable I (integers 1,...,g), using the method specified:
00005 %
00006 %   method = 1:   0/-1/1 coding, full rank
00007 %   method = 2:   0/1 coding, full rank
00008 %   method = 3:   0/1 coding, overdetermined
00009 
00010 %   Copyright 1993-2002 The MathWorks, Inc. 
00011 %   $Revision: 1.26 $  $Date: 2005/06/22 18:02:41 $
00012 
00013 if (nargin < 2)
00014    method = 1;
00015 end
00016 
00017 n = length(x);
00018 g = max(x);
00019 ncols = g - (method ~= 3);
00020 d = repmat(0, n, ncols);
00021 
00022 if (g > 1)
00023    % Fill in -1 for the first level
00024    if (method == 1)
00025       i = find(x == 1);
00026       d(find(x == 1),:) = -1;
00027    end
00028    
00029    % Fill in 1 in the appropriate column for other levels
00030    m3 = (method == 3);
00031    for j=(2-m3):g
00032       d(find(x == j),j-1+m3) = 1;
00033    end
00034 end
 

Powered by Plone

This site conforms to the following standards: