Skip to content

Instantly share code, notes, and snippets.

@samtx
Created July 21, 2016 05:36
Show Gist options
  • Save samtx/61265a869a04d2c8eee9fe9f314d0c2a to your computer and use it in GitHub Desktop.
Save samtx/61265a869a04d2c8eee9fe9f314d0c2a to your computer and use it in GitHub Desktop.
function mat = np2mat(npary)
% convert python (Numpy) ndarray to matlab
sh = double(py.array.array('d',npary.shape));
npary2 = double(py.array.array('d',py.numpy.nditer(npary)));
mat = reshape(npary2,fliplr(sh))'; % matlab 2d array
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment