%% Sample training script for using Matlab's built-in RBF functions % Synthetic data: Two dimensional sine wave. First, we'll take a look at % the data (no changes need to be made here) [X,Y]=meshgrid(-1:0.1:8); Z=sin(X/4).*sin(Y/2); figure(1); surf(X,Y,Z); title('Original surface before noise'); %Training stuff here: Patterns=9*rand(2,300)-1; %Dimension x Number of Points for newrb Targets=sin(Patterns(1,:)/4).*sin(Patterns(2,:)/2)+0.01*randn(size(Patterns(1,:))); goal=0.1; spread=1.0; MaxCenters=200; DisplayRate=10; %Redo the graph every 10 iterations net=newrb(Patterns,Targets,goal,spread,MaxCenters,DisplayRate); % Plotting routines again: [mm,nn]=size(X); Xtest=[X(:)';Y(:)']; Zout=sim(net,Xtest); Zout=reshape(Zout,mm,nn); figure(2) surf(X,Y,Zout); title('Modeled surface'); % % Manually performing the simulation of the network: % This shows you what Matlab's "net" structure holds % Centers=net.IW{1,1}; Weights=net.LW{2,1}; spr=net.b{1}(1); bias=net.b{2}; A=radbas(dist(Xtest',Centers').*spr); Zout2=A*Weights'+bias;