Advertisement
Nikitka_36

NS L9

Apr 9th, 2015
486
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.53 KB | None | 0 0
  1. clear;
  2. p = rand(1,100)*100
  3. t = zeros(1,100)
  4. for i=1:100
  5.     if p(i) < 50
  6.         t(i) = 1;
  7.     else
  8.         t(i) = 2;
  9.     end;
  10. end;
  11.        
  12.  t1 = ind2vec(t)
  13.  hold on;
  14.  
  15.  net = newlvq(minmax(p), 8, [0.5 0.5], 0.02);
  16.  net.trainParam.Epochs = 150;
  17.  net = train(net, p, t1);
  18.  
  19.  y = vec2ind(sim(net,p))
  20.  figure;
  21.  hold on;
  22.  for i=1:length(y)
  23.      switch y(i)
  24.          case 2, plot(p(i),t(i),'r*')
  25.          case 1, plot(p(i), t(i),'g*')
  26.      end
  27.  end;
  28.  xlabel('Pi');
  29.  ylabel('T');
  30.  title('сеть lvq');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement