daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Jun 25th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function zadacha
  2.  
  3. % Инициализиране на матрицата А
  4. A=[4,1; -3, 4]
  5.  
  6. % Вектор стълб със свободните членове
  7. rhs=[5;1]
  8.  
  9. % Равновесната точка
  10. a=A\(-rhs)
  11.  
  12. % Намиране на собствените стойности в D
  13. D=eig(A)
  14.  
  15. x=a(1)-4:a(1)+4
  16. y=a(2)-4:a(2)+4
  17.  
  18. hold on
  19.  
  20. axis([a(1)-7,a(1)+7,a(2)-9,a(2)+9])
  21.  
  22. % Функция за дясната страна
  23. function z= ff(t,y)
  24.     z=A*y+rhs
  25. end  
  26.  
  27. % фазови криви
  28. [X,Y]=meshgrid(x,y);
  29. tmax=50;
  30. for i=1:length(x)
  31.     for j=1:length(y)
  32.         [U,Z]=ode45(@ff,[0,tmax],[X(i,j),Y(i,j)]);
  33.         [U1,Z1]=ode45(@ff,[0,-tmax],[X(i,j),Y(i,j)]);
  34.         plot(Z(:,1),Z(:,2),Z1(:,1),Z1(:,2),'b');
  35.     end
  36. end
  37.  
  38. % тангенциални вектори
  39. % P и Q са  вектори v(f(x,y),g(x,y)
  40. P=A(1,1)*X+A(1,2)*Y+rhs(1);
  41. Q=A(2,1)*X+A(2,2)*Y+rhs(2);
  42. D=sqrt(P .^2+Q.^2);
  43. quiver(X,Y ,P ./D,Q./D,0.5,'r')
  44.  
  45. plot(a(1),a(2),'m*')
  46.  
  47. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top