Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function indices = saddle(M)
- [nrows, ncols] = size(M)
- [a, b] = max(M, [], 2);
- [c, d] = min(M, [], 1);
- sad = (kron(a, ones(1, ncols)) == M).*(kron(ones(nrows, 1), c) == M);
- if sum(sad, 'all') >= 1
- [k, d] = find(sad);
- [f1, f2] = size(sad);
- if f2==1 | (f1>2 & f2>2)
- indices = cat(2, k, d);
- else
- indices = cat(2, k.', d.');
- end
- else
- indices = [];
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement