%% Sample RBF script % Data is one dimensional in this case x=linspace(-3,3,100); y=sin(3*x); temp=randperm(100); Xtrain=x(temp(1:10)); Ytrain=y(temp(1:10)); Xtest=x(temp(11:end)); Ytest=y(temp(11:end)); %% Compute the RBF %Choose the centers at random from the data numcenters=13; temp=randperm(100); Centers=x(temp(1:numcenters)); A=edm(Xtrain',Centers'); Phi=rbf1(A,6); alpha=pinv(Phi)*Ytrain'; %% Test the model % For plotting purposes, we'll test the model on all the data A=edm(x',Centers'); Phi=rbf1(A,6); Yout=Phi*alpha; plot(Xtrain,Ytrain,'k*',x,y,x,Yout);