Advertisement
allozo

Untitled

Mar 23rd, 2022
726
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. a11 = -0.4;
  2. a12 = -0.8;
  3. a21 = 1;
  4. a22 = -0.3;
  5.  
  6. b1 = -1.4;
  7. b2 = 0.08;
  8.  
  9. c = 0.9;
  10. d = 0.0086;
  11. T = 0.12;
  12.  
  13. A = [
  14.     a11 a12  b1;
  15.     a21 a22  b2;
  16.     0   0   -1/T
  17.     ];
  18.  
  19. B = [
  20.     0; 0; 1/T
  21.     ];
  22.  
  23. syms omega_z(t) alpha(t) delta(t) u(t) n_y(t)
  24.  
  25. assume(t, "real")
  26.  
  27. n_y = c * alpha + d * delta;
  28.  
  29. X = [omega_z; alpha; delta];
  30. X_star = [omega_z; n_y; delta];
  31.  
  32. % Получим матрицу T
  33. % Матрица Т состоит из нулей кроме 3-х элементов: t_11 = 1; t_22 = 1/c;
  34. % t_23 = -d/c
  35.  
  36. matrix_T = [
  37.             1   0    0;
  38.             0 1/c -d/c;
  39.             0   0    1
  40.             ];
  41.  
  42. % X == matrix_T * X_star
  43.  
  44. Уравнение в изначальном виде:
  45. dX = diff(X, t);
  46. dX_star = diff(X_star, t);
  47.  
  48. eq1 = dX == A*X + B*u;
  49. Уравнение при переходе к новому базису:
  50. A_star = inv(matrix_T)*A*T
  51. B_star = inv(matrix_T)*B
  52. % dX_star == A_star * X_star + B_star * u
  53. tmp = @(t, omega_z, n_y, delta) A_star * X_star + B_star * u
  54.  
  55.  
  56.  
  57.  
  58. tspan = [0 3];
  59. y0 = -5:5;
  60. tmp1 = ode45(tmp, tspan, y0)
  61. plot(t, tmp1(:, 2), '-.')
  62.  
  63. % A = 1;
  64. % B = 2;
  65. % tspan = [0 5];
  66. % y0 = [0 0.01];
  67. % [t,y] = ode45(@(t,y) odefcn(t,y,A,B), tspan, y0);
  68. %
  69. % plot(t, y(:,1), '-o', t, y(:,2), '-.')
  70. tmp;
  71.  
  72. function dydt = odefunc(t, exp)
  73.     dydt = zeros(3, 1);
  74.     dydt(1) = 1;
  75. end
  76.  
  77.  
  78. function dydt = odefcn(t,y,A,B)
  79.   dydt = zeros(2,1);
  80.   dydt(1) = y(2);
  81.   dydt(2) = (A/B)*t.*y(1);
  82. end
  83.  
Advertisement
RAW Paste Data Copied
Advertisement