kamilosxd678

Cramcio

Apr 4th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function [ans] = Cramer ( A, B)
  2. %cramer
  3. n = size(B, 1);
  4. ans = 0;
  5. wA = det(A);
  6. %rozwiazania
  7. AB = [A B];
  8. m = size(A, 2);
  9. if (rank(A) ~= rank(AB))
  10. rozwiazania = 0;
  11. elseif (rank(A) == rank(AB))
  12. if (rank(A) == m)
  13. rozwiazania = 1;
  14. else
  15. rozwiazania = -1;
  16. end
  17. end
  18. %policzenie
  19. if (rozwiazania==1) && (det(A) ~= 0)
  20. for i=1:n
  21. temp = A;
  22. temp(:, i) = B;
  23. ans(i, 1) = 1/wA * det(temp);
  24. end
  25. end
Advertisement
Add Comment
Please, Sign In to add comment