Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.70 KB | None | 0 0
  1. clc;
  2. clear all;
  3. close all;
  4.  
  5. load('lab8_4.mat');
  6.  
  7. yid = id.Y;
  8. uid = id.U;
  9.  
  10. plot(id)
  11.  
  12. counter = 1;
  13. theta(:,counter) = [.20; 1];
  14.  
  15. alpha = 0.00001;
  16. N = length(yid);
  17.  
  18. [E,e]=epsilon(theta,uid,yid,N);
  19. V=gradient(E,e,N);
  20. H=hessian(e,N);
  21. theta(:, counter+1) = theta(:,counter) - alpha*inv(H)*V;
  22. counter = counter + 1;
  23.  
  24. while (counter <= N || norm(theta(:,counter) - theta(:,counter-1)) >= 1e-6)
  25.     [E,e]=epsilon(theta,uid,yid,N);
  26.     V=gradient(E,e,N);
  27.     H=hessian(e,N);
  28.     theta(:, counter+1) = theta(:,counter) - alpha*inv(H)*V;
  29.     counter = counter+1;
  30. end
  31.  
  32. thetap = theta(:, counter);
  33. B=[0 thetap(2,1)];
  34. F=[1 thetap(1,1)];
  35. model = idpoly(1,B,1,1,F,0,id.Ts);
  36. figure;
  37. compare(model, val);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement