function [G]=makeg(dim, m1, derivatives, sigma) % % Usage: G = makeg(dim, m1, derivatives, sigma) % % makeg will create a (dim x dim) DGT matrix with basis functions in the columns. % There are m1 basis functions at each location. 'derivatives' and 'sigma' are % length m1 vectors specifying the derivative orders of each basis function at a % location and the standard deviations of the Gaussians from which each derivative % is generated. A good basis set, with m1 = 8, is: % derivatives = [ 0 3 10 21 36 53 74 99]; % sigma = [3.4 3.4 3.4 3.4 3.4 3.4 3.4 3.4]' % % This set of m1 basis functions is then shifted to dim/m1 uniformly distributed % locations. % Written by Jeffrey A Bloom. % % This function calls the following M-file functions: % DG.m %-------------------- % General variables %-------------------- disp(' makeg called with sigma ');disp(sigma); disp(' and orders ');disp(derivatives); offset=(m1-1)/2; longdim=2*dim-1; param= [0,longdim,0,(longdim+1)/2+offset]; % initial value % param = [n,dim,sigma,loc] locations = (0:(dim/m1-1))*m1 + 1 + offset; %----------------------- % Generate the G matrix %----------------------- % There are m1 basis functions which are then shifted to get the rest. % LongG are the m1 functions, doubly long to allow proper shifting LongG = zeros(longdim,m1); for j=1:m1 param(3) = sigma(j); param(1) = derivatives(j); LongG(:,j) = DG(param)'; end for j=1:m1 for i=1:dim/m1 start = (longdim+1)/2 - (i-1)*m1; G(:,(j-1)*dim/m1+i) = LongG(start:start+dim-1,j); end end %---------------------------- % Normalize the columns of G %---------------------------- disp(' Normalizing G') Gmax = max(G); % This returns a row vector with each element the max of % the corresponding column in G G = G./Gmax(ones(dim,1),:)*10; % Now all columns of G have a max of 10. return % end function