X=[1 1 1 %Data with labels as the third column. 1 2 1 2 -1 2 2 0 2 -1 2 3 -2 1 3 -1 -1 4 -2 -2 4]; C=[1 1.5 % 4 centers in R^2 2 0.5 -1.5 1.5 -1.5 -1.5]; P=X(:,1:2); %P stands for patterns [numpts,dim]=size(P); T=X(:,3); %T stands for target values %The EDM matrix should be 8 x 4, then add a column of ones A=edm(P,C); sigma2=1; Phi=exp(-(A.^2)./sigma2); Phi(:,5)=ones(numpts,1); Coefs=pinv(Phi)*T; %The model equation is Phi*Coefs=T %We'll evaluate the model for lots of data in the plane % and plot the results [Xx,Yy]=meshgrid(-3:0.1:3,-3:0.1:3); [mm,nn]=size(Xx); DomX=[Xx(:), Yy(:)]; %Number of points by 2 [numpts2,dim]=size(DomX); A2=edm(DomX,C); %Number of points by 4 Phi2=exp(-(A2.^2)./sigma2); Phi2(:,5)=ones(numpts2,1); Z=Phi2*Coefs; %Sample outputs surf(Xx,Yy,reshape(Z,mm,nn)); shading('interp')