Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions content/numpy-for-matlab-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ arguments are two-dimensional entities.

* - `[x,y]=meshgrid(0:8,0:5)`
- `np.mgrid[0:9.,0:6.]` or `np.meshgrid(np.r_[0:9.],np.r_[0:6.])`
- two 2D arrays: one of x values, the other of y values
- two 2D arrays: one of x values, the other of y values. `np.meshgrid`
returns 6x9 arrays, like MATLAB. `np.mgrid` uses matrix (`'ij'`)
indexing, so it returns their 9x6 transposes, x values first.

* -
- `np.ogrid[0:9.,0:6.]` or `np.ix_(np.r_[0:9.],np.r_[0:6.])`
Expand Down Expand Up @@ -523,19 +525,24 @@ arguments are two-dimensional entities.

* - `fft(a)`
- `np.fft.fft(a)`
- Fourier transform of `a`
- Fourier transform of `a`. For a 2D array, MATLAB transforms each
column, while NumPy transforms along the last axis (each row) by
default. Use `np.fft.fft(a, axis=0)` to match MATLAB.

* - `ifft(a)`
- `np.fft.ifft(a)`
- inverse Fourier transform of `a`
- inverse Fourier transform of `a`. As with `fft`, use
`np.fft.ifft(a, axis=0)` to match MATLAB for a 2D array.

* - `sort(a)`
- `np.sort(a, axis=0)` or `a.sort(axis=0)`
- sort each column of a 2D array, `a`
- sort each column of a 2D array, `a`. `np.sort` returns a sorted copy,
like MATLAB, while `a.sort` sorts `a` in place and returns `None`.

* - `sort(a, 2)`
- `np.sort(a, axis=1)` or `a.sort(axis=1)`
- sort the each row of 2D array, `a`
- sort each row of a 2D array, `a`. As above, `a.sort` sorts `a` in
place.

* - `[b,I]=sortrows(a,1)`
- `I = np.argsort(a[:, 0]); b = a[I,:]`
Expand Down
Loading