Also , for my above problem
can I use this code ? how should I change it for this ?
no_of_points=5000; %no. training points of each Set
center1=[0,0]'; center2=[0,4]';
sigma1=1; sigma2=4;
%randn('seed',10);
p1=randn(2,no_of_points)*sigma1;
p1(1,:)=p1(1,:)+center1(1); p1(2,:)=p1(2,:)+center1(2);
t1= ones(1,no_of_points);
p2=randn(2,no_of_points)*sigma2;
p2(1,:)=p2(1,:)+center2(1); p2(2,:)=p2(2,:)+center2(2);
t2= -ones(1,no_of_points);
p = [p1,p2]; %training set (input)
t = [t1,t2]; %training set (output)
lr= 0.0001; %learning rate
%Initialize 2-2-1 network
rand('seed',0);
% randn('seed',0);
net=newff(minmax(p),[10,1],{'tansig','purelin'},'trainlm');
%net=newff(minmax(p),[10,1],{'tansig','purelin'},'traingdx');
net.trainParam.lr=0.1;
net.trainParam.epochs=20;
net.trainParam.show =50;
net = train(net,p,t); %Batch learning
a = sim(net,p); %Net Simulation
a_01=a;
ii=find(a > 0);
a_01(ii)=ones(size(ii));
ii=find(a < 0);
a_01(ii)=-1*ones(size(ii));
ii=find((a_01-t)==0);
correct_classif_percent=length(ii)/length(t);
fprintf(1,'Correct Classification = %5.2f %%\n',correct_classif_percent*100);
% --- Data Representation ---
%data preparation
x=[-5: 0.5 :5];
y=[-5: 0.5 :10];
[xx,yy]=meshgrid(x,y);
p_glob=[xx(:), yy(:)]'; % (input)
a_glob=sim(net,p_glob); %simulate
[ny,nx]=size(xx);
a_glob_zz=reshape(a_glob,ny,[]);
%plot results
figure(1);clf;
ii=find(t==-1);
plot(p(1,ii),p(2,ii),'o');
hold on
ii=find(t==1);
plot(p(1,ii),p(2,ii),'.m');
[c,h]=contour(xx,yy,a_glob_zz,[0 0]);
set(h,'LineWidth',2)
set(h,'EdgeColor',[0,0 0]);
axis image;
%return;
%plot results
figure(2);clf;
surf(xx,yy,a_glob_zz);
hold on
%mesh(xx,yy,a_zz);
h=plot3(c(1,2:end),c(2,2:end),zeros(1,length(c(2,2:end))));
set(h,'LineWidth',3)
set(h,'Color','k')
title('Neural network Surface');