Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. close all
  2. clear all
  3. Pop=eye(4)*100;
  4. up1=0;
  5. yp1=0;
  6. yp2=0;
  7. Teta=[0;0;0;0];
  8. zadane=[0.7;0.25;1;1];
  9. a=0.5;
  10. b=0.25;
  11. c=1;
  12. d=1;
  13.  
  14. lambda=input('podaj wartosc parametru lambda:\n');
  15. N=input('podaj ile pomiarow chcesz wykonac (powinno byc wiecej niz 12000):\n');
  16. v=zeros(4,N);
  17. j=1:N;
  18. for i=1:N
  19. u=rand(1);
  20. E=(rand(1)-0.5)/1;
  21. y=a*yp1+b*yp2+c*u+d*up1+E;
  22. Phi=[yp1;yp2;u;up1];
  23. Pop=(1/lambda)*(Pop-((((Pop*Phi)*Phi')*Pop)/(lambda+((Phi'*Pop)*Phi))));
  24. Teta=Teta+Pop*Phi*(y-Phi'*Teta);
  25.  
  26. yp2=yp1;
  27. yp1=y;
  28. up1=u;
  29. if i==10000
  30. a=0.7;
  31. %q=1000;
  32. end
  33. v(:,i)=Teta(:,1);
  34.  
  35. end
  36. for z=1:4
  37. figure(z);
  38. plot(j,v(z,:));
  39. xlabel 'czas'
  40. title 'odpowiedz ukladu na zmiane parametru a z 0.5 na 0.7'
  41. legend (strcat('\lambda=', num2str(lambda)));
  42. if z==1
  43. ylabel 'a'
  44. end
  45. if z==2
  46. ylabel 'b'
  47. end
  48. if z==3
  49. ylabel 'c'
  50. end
  51. if z==4
  52. ylabel 'd'
  53. end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement