Guest User

Untitled

a guest
May 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.04 KB | None | 0 0
  1. [X_ucz, Y_ucz] = meshgrid(-20:0.2:20,-20:0.2:20);
  2. punkt_uczenie = [X_ucz(:)'; Y_ucz(:)'];
  3.  
  4. [X_test, Y_test] = meshgrid(-20:0.2:20,-20:0.2:20);
  5. punkt_test = [X_test(:)'; Y_test(:)'];          
  6.  
  7. funkcja_uczenie = 0.5+((sin(sqrt(X_ucz.^2+Y_ucz.^2)-0.5)).^2)./((1+0.001*(X_ucz.^2+Y_ucz.^2)).^2);    
  8. funkcja_test = 0.5+((sin(sqrt(X_test.^2+Y_test.^2)-0.5)).^2)./((1+0.001*(X_test.^2+Y_test.^2)).^2);  
  9.  
  10. figure(1);
  11. mesh(X_test,Y_test,funkcja_test);                        
  12. title('Wykres funkcji aproksymowanej');
  13. axis([-20 20 -20 20 0 2]);
  14.  
  15. net = newff([-20 20; -20 20],[10 10 1],{'tansig' 'tansig' 'purelin'},'trainlm');  
  16. net.trainParam.epochs = 100;              
  17. net.trainParam.goal = 1e-10;                
  18.  
  19. net = init(net);                    
  20. [net tr] = train(net,punkt_uczenie,funkcja_uczenie(:)');
  21.                          
  22. Z = sim(net,punkt_test);                      
  23. Z = reshape(Z,size(X_test));
  24.    
  25. figure(3);
  26. mesh(X_test,Y_test,Z);                          
  27. title('Wykres funkcji aproksymujÄ…cej');
  28. axis([-20 20 -20 20 0 2]);
Add Comment
Please, Sign In to add comment