function M=gen_mm(ord,N0) % GEN_MM Computes the matrix belonging to a special canonical pattern. % % [M] = GEN_MM(ord,N0) % % This function file calculates a special canononical pattern in a diagonal % manner, of matrix size M by M+ord, where ord is the order. % % Inputs: % ord = order of the canonical pattern % N0 = size of matrix % % Output: % M = Resulting covariance matrix % % % (C) Gaussian Process Toolbox 1.0 % (C) Copyright 2005-2007, Keith Neo % http://www.hamilton.ie M=zeros(N0,N0+ord); if (iseven(ord)==1) for m=1:N0 for n=m:m+ord M(m,n)=ncr(ord,n-m)*(-1)^(n-m); end end else for m=1:N0 for n=m:m+ord M(m,n)=ncr(ord,n-m)*(-1)^(n-m+1); end end end function x=ncr(n,r) x=factorial(n)/factorial(n-r)/factorial(r);