def find(a,n=None,d=None,nargout=1):
if d:
raise NotImplementedError
# there is no promise that nonzero or flatnonzero
# use or will use indexing of the argument without
# converting it to array first. So we use asarray
# instead of asanyarray
if nargout == 1:
i = np.flatnonzero(np.asarray(a)).reshape(1,-1)+1
if n is not None:
i = i.take(n)
return matlabarray(i)
if nargout == 2:
i,j = np.nonzero(np.asarray(a))
if n is not None:
i = i.take(n)
j = j.take(n)
return (matlabarray((i+1).reshape(-1,1)),
matlabarray((j+1).reshape(-1,1)))
raise NotImplementedError
评论列表
文章目录