Advertisement
MLCPRO

kr2

Jan 29th, 2022
1,037
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %Исходные данные
  2. A = [10.8,0.0475,0,0;
  3.     0.0321,9.9,0.0523,0;
  4.     0,0.0369,9,0.057;
  5.     0,0,0.0416,8.1;];
  6.  
  7. B = [12.143,13.0897,13.6744,13.8972];
  8.  
  9. %размер системы
  10. N = max(size(B));
  11.  
  12. x = zeros(1,N);
  13.  
  14. v = zeros(1,N);
  15. u = zeros(1,N);
  16.  
  17. %прямой прогон
  18. v(1) = A(1,2) / (-A(1,1));
  19. u(1) = (-B(1)) / (-A(1,1));
  20.  
  21. for i = 2:(N-1)
  22.     v(i) = A(i,i+1) / (-A(i,i) - A(i,i-1)*v(i-1));
  23.     u(i) = (A(i,i-1)*u(i-1) - B(i)) / (-A(i,i) - A(i,i-1)*v(i-1));
  24. end;
  25.  
  26. v(N) = 0;
  27. u(N) = (A(N,N-1)*u(N-1)-B(N)) / (-A(N,N) - A(N,N-1)*v(N-1));
  28. % обратный прогон
  29. x(N) = u(N);
  30. for i = (N-1):-1:1
  31.     x(i) = v(i) * x(i+1) + u(i);
  32. end;
  33.  
  34. disp(x)
  35.  
  36.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement