Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- P=[-3, -2, 3;
- 1, -1, 5;
- -8, -4, 4];
- A=P;
- [lw, lk]=size(A);
- 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);
- disp("Wyznacznik: ");
- disp(detA);
- X=det(P);
- disp("Sprawdzenie wyznacznika: ");
- disp(X);
- if detA!=0
- i=3;
- j=3;
- D=zeros(3,3);
- 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));
- disp("macierz dope�nien: ");
- disp(D);
- DT=zeros(lw,lk);
- for i=1:lw
- for j=1:lk
- DT(j,i)=D(i,j);
- end
- end
- disp("Macierz dope�nie� transponowana: ");
- disp(DT);
- P_odwrotne=(1/detA)*DT;
- disp("Macierz odwrotna");
- disp(P_odwrotne);
- disp("Sprawdzenie macierzy odwrotnej: ");
- disp(inv(P));
- else
- disp("Wyznacznik rowny 0 -> brak macierzy odwrotnej");
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement