Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A=[4,-7,0,11,8;0,9,-4,0,6;3,5,7,1,9;5,1,9,-3,5;-9,-11,3,9,0];
- Y=[2;10;17;3;5];
- X=zeros(5,1);
- if det(A)!=0
- R=[A*Y];
- vec_pom=zeros(1,7);
- if R(1,1)==0
- if R(2,1)!=0
- vec_pom=R(1,:);
- R(1,:)=R(2,:);
- R(2,:)=vec_pom;
- else
- vec_pom=R(1,:);
- R(1,:)=R(5,:);
- R(5,:)=vec_pom;
- end;
- end
- mnoznik=-R(2,1)/R(1,1);
- vec_pom=R(1,:)*mnoznik+R(2,:);
- R(5,:)=vec_pom;
- mnoznik=-R(5,1)/R(1,1);
- vec_pom=R(1,:)*mnoznik+R(5,:);
- R(5,:)=vec_pom;
- disp("Macierz R po wyzerowaniu R(1,1)");
- disp(R);
- if R(5,1)==0
- vec_pom=R(2,:);
- R(2,:)=R(5,:);
- R(5,:)=vec_pom;
- end
- mnoznik=-R(5,1)/R(4,1);
- vec_pom=R(2,:)*mnoznik+R(3,:);
- R(3,:)=vec_pom;
- disp("Macierz R po wyzerowaniu R(2,2)");
- disp(R);
- X(3,1)=R(5,1)/R(4,1);
- X(2,1)=(R(5,1)-R(4,1)*X(3,1))/R(1,1);
- X(1,1)=(R(5,1)-R(4,1)*X(3,1)-R(2,1)*X(1,1))/R(1,1);
- disp("Rozwiązanie rownania X");
- disp(X);
- else
- disp("Podany układ równań nie jest układem oznaczonym");
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement