Skip to content

Instantly share code, notes, and snippets.

@mizunototori
Created August 31, 2017 01:49
Show Gist options
  • Save mizunototori/9b26f8b5bdcccabdadb460da7dcfffc1 to your computer and use it in GitHub Desktop.
Save mizunototori/9b26f8b5bdcccabdadb460da7dcfffc1 to your computer and use it in GitHub Desktop.
python ind2sub same with matlab
def ind2sub(array_shape, ind):
# Gives repeated indices, replicates matlabs ind2sub
rows = (ind.astype("int32") // array_shape[1])
cols = (ind.astype("int32") % array_shape[1])
return (rows, cols)
@mizunototori
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment