%Script file: HW13B.m load Sunspot11 % Build the training set and the testing set: Label them Htrain, Htest, % Ttrain, Ttest, respectively: T=T'; %temp=randperm(300); temp=1:300; Htrain=H(:,temp(1:150)); Ttrain=T(:,temp(1:150)); Htest=H(:,temp(151:300)); Ttest=T(:,temp(151:300)); d=sqrt(sum(H.*H)); m=max(d); % Build the RBF: Save the result as "net". net=newrb(Htrain,Ttrain,10,m/2); % Simulate the network using two sets: First, output the result for all % data, then output the result on the testing set, and plot the result. Yfull= sim(net, H); %simulate the network on all data Ytest= sim(net, Htest); %simulate the network on just the testing data % Visualize the results (we're not plotting the years, only the index) % You shouldn't have to change this: plot(1:length(T),T,1:length(T),Yfull,'r-') hold on plot(151:300,Ytest,'g*'); hold off Centers = net.IW{1,1}; Weights = net.LW{2,1};