%Script file to show linear regression using the EDM: X=randn(30,2); Y=exp(-(X(:,1).^2+X(:,2).^2)./4); temp=randperm(30); C=X(temp(1:10),:); A=edm(X,C); Phi=rbf1(A,2); alpha=pinv(Phi)*Y; Z=Phi*alpha; plot3(X(:,1),X(:,2),Y,'r*',X(:,1),X(:,2),Z,'b^'); hold on %Create a 3-d surface [X1,Y1]=meshgrid(-2:0.125:2); [m,n]=size(X1); for j=1:m for k=1:n Z(j,k)=0; for t=1:10 temp=rbf1(norm([X1(j,k) Y1(j,k)]-C(t,:)),2); Z(j,k)=Z(j,k)+alpha(t)*temp; end end end meshc(X1,Y1,Z); hold off