/usr/share/psychtoolbox-3/PsychOneliners/FindInd.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | function varargout = FindInd(in, k, mode)
% find that also does higher dims for output like [x,y,x,t] = findfull(4-D)
% (unlimited of course)
%
% steal from MinInd, and then edit MinInd and MaxInd
% DN 2008-07-29 Wrote it
% input/output checking
if nargin == 3
switch mode
case 'first'
qfirst = true;
case 'last'
qfirst = false;
otherwise
error('mode %s not recognized',mode)
end
elseif nargin == 2
qfirst = true;
end
psychassert(nargout==0 || nargout==1 || nargout==ndims(in),'number of outputs must be one or equal to the number of dimensions of the input')
% do the work
inds = find(in);
if nargin==2 || nargin==3
if qfirst
inds = inds(1:k);
else
inds = inds(end-k+1:end);
end
end
[varargout{1:ndims(in)}] = ind2sub(size(in),inds(:));
% output
if nargout==0 || nargout==1
varargout = {[varargout{:}]};
end
|