Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 1.09 KB | None | 0 0
  1. P=[-3, -2, 3;
  2.     1, -1, 5;
  3.     -8, -4, 4];
  4. A=P;
  5. [lw, lk]=size(A);
  6.  
  7. detA=A(1,1)*A(2,2)*A(3,3) + A(1,2)*A(2,3)*A(3,1) + A(1,3)*A(2,1)*A(3,2)-A(1,3)*A(2,2)*A(3,1) - A(1,1)*A(2,3)*A(3,2) - A(1,2)*A(2,1)*A(3,3);
  8.  
  9. disp("Wyznacznik: ");
  10. disp(detA);
  11. X=det(P);
  12. disp("Sprawdzenie wyznacznika: ");
  13. disp(X);
  14. if detA!=0
  15.  i=3;
  16.  j=3;
  17.  D=zeros(3,3);
  18.  D(1,1)=(P(2,2)*P(3,3)-P(3,2)*P(2,3));
  19.  D(1,2)=(P(2,1)*P(3,3)-P(2,3)*P(3,1))*(-1);
  20.  D(1,3)=(P(2,1)*P(3,2)-P(1,2)*P(3,1));
  21.  D(2,1)=(P(1,2)*P(3,3)-P(1,3)*P(3,1))*(-1);
  22.  D(2,2)=(P(1,1)*P(3,3)-P(1,3)*P(3,1));
  23.  D(2,3)=(P(1,1)*P(3,3)-P(1,2)*P(3,1))*(-1);
  24.  D(3,1)=(P(1,2)*P(2,3)-P(1,3)*P(2,2));
  25.  D(3,2)=(P(1,1)*P(2,3)-P(1,3)*P(2,1))*(-1);
  26.  D(3,3)=(P(1,1)*P(2,2)-P(1,2)*P(2,1));
  27.  disp("macierz dope�nien: ");
  28.  disp(D);
  29.  DT=zeros(lw,lk);
  30.  for i=1:lw
  31.   for j=1:lk
  32.     DT(j,i)=D(i,j);
  33.   end
  34.  end
  35.  disp("Macierz dope�nie� transponowana: ");
  36.  disp(DT);
  37.  P_odwrotne=(1/detA)*DT;
  38.  disp("Macierz odwrotna");
  39.  disp(P_odwrotne);
  40.  disp("Sprawdzenie macierzy odwrotnej: ");
  41.  disp(inv(P));
  42. else
  43.  disp("Wyznacznik rowny 0 -> brak macierzy odwrotnej");
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement