1
function [s]=center(x,orient)
3
//This function computes s, the centered version of the
6
//For a vector or a matrix x, s=center(x) returns in the
7
//(i,j) coefficient of the matrix s the value
8
//(x(i,j)-xbar), where xbar is the mean of the values of
9
//the coefficients of x.
11
//s=center(x,'r') (or, equivalently, s=center(x,1)) is the
12
//rowwise center reduction of the values of x. It returns
13
//in the entry s(i,j) the value (x(i,j)-xbarv(j)) with
14
//xbarv(j) the mean of the values of the j column.
16
//s=center(x,'c') (or, equivalently, s=center(x,2)) is the
17
//columnwise centre reduction of the values of x. It
18
//returns in the entry s(i,j) the value (x(i,j)-xbarh(i))
19
//with xbarh(i) the mean of the values of the i row.
21
//author: carlos klimann
25
if x==[] then s=%nan, return, end
27
if (rhs<1)|(rhs>2) then error('center requires one or two inputs.'), end
32
elseif orient=='c'|orient==2 then
35
elseif orient=='r'|orient==1 then
38
else error('Second center parameter must be r, c, 1 or 2'),