SHARE
TWEET

Untitled

a guest Jun 26th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top