Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Octave 0.99 KB | None | 0 0
  1. %Zad.1
  2. A=[2,3,1; 4,1,2; 3,5,1];
  3. 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);
  4. disp("Wyznacznik Macierzy A:"); disp(detA); disp("Sprawdzenie"); disp(det(A));
  5. %Zad.2
  6. P=[-3,-2,3; 1,-1,5; -8,-4,4];
  7. detP=P(1,1)*P(2,2)*P(3,3)+P(1,2)*P(2,3)*P(3,1)+P(1,3)*P(2,1)*P(3,2)-P(1,3)*P(2,2)*P(3,1)- P(1,1)*P(2,3)*P(3,2)-P(1,2)*P(2,1)*P(3,3);
  8. if detP!=0
  9. D(1,1)=(P(2,2)*P(3,3)-P(3,2)*P(2,3)); D(1,2)=(P(2,1)*P(3,3)-P(2,3)*P(3,1))*(-1); D(1,3)=(P(2,1)*P(3,2)-P(1,2)*P(3,1)); D(2,1)=(P(1,2)*P(3,3)-P(1,3)*P(3,1))*(-1); D(2,2)=(P(1,1)*P(3,3)-P(1,3)*P(3,1)); D(2,3)=(P(1,1)*P(3,3)-P(1,2)*P(3,1))*(-1); D(3,1)=(P(1,2)*P(2,3)-P(1,3)*P(2,2)); D(3,2)=(P(1,1)*P(2,3)-P(1,3)*P(2,1))*(-1); D(3,3)=(P(1,1)*P(2,2)-P(1,2)*P(2,1));
  10. DT=zeros(3,3); for i=1:3
  11. for j=1:3
  12. DT(j,i)=D(i,j); end
  13. end P_odw=(1/detP)*DT;
  14. disp("Macierz odwrotna:"); disp(P_odw); disp("Sprawdzenie") disp(inv(P));
  15. else
  16. disp("Macierz nie posiada macierzy odwrotnej");
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement