Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ans] = Cramer ( A, B)
- %cramer
- n = size(B, 1);
- ans = 0;
- wA = det(A);
- %rozwiazania
- AB = [A B];
- m = size(A, 2);
- if (rank(A) ~= rank(AB))
- rozwiazania = 0;
- elseif (rank(A) == rank(AB))
- if (rank(A) == m)
- rozwiazania = 1;
- else
- rozwiazania = -1;
- end
- end
- %policzenie
- if (rozwiazania==1) && (det(A) ~= 0)
- for i=1:n
- temp = A;
- temp(:, i) = B;
- ans(i, 1) = 1/wA * det(temp);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment