Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. function indices = saddle(M)
  2. [nrows, ncols] = size(M)
  3. [a, b] = max(M, [], 2);
  4. [c, d] = min(M, [], 1);
  5. sad = (kron(a, ones(1, ncols)) == M).*(kron(ones(nrows, 1), c) == M);
  6. if sum(sad, 'all') >= 1
  7. [k, d] = find(sad);
  8. [f1, f2] = size(sad);
  9. if f2==1 | (f1>2 & f2>2)
  10. indices = cat(2, k, d);
  11. else
  12. indices = cat(2, k.', d.');
  13. end
  14. else
  15. indices = [];
  16. end
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement