Skip to content
Merged
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
28 changes: 14 additions & 14 deletions content/numpy-for-matlab-users.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ arguments are two-dimensional entities.
- Notes

* - `help func`
- `info(func)` or `help(func)` or `func?` (in IPython)
- `np.info(func)` or `help(func)` or `func?` (in IPython)
- get help on the function *func*

* - `which func`
- [see note HELP](#notes)
- find out where *func* is defined

* - `type func`
- `np.source(func)` or `func??` (in IPython)
- `inspect.getsource(func)` (after `import inspect`) or `func??` (in IPython)
- print source for *func* (if not a native function)

* - `% comment`
Expand Down Expand Up @@ -182,11 +182,11 @@ arguments are two-dimensional entities.
will create a dictionary with the saved arrays and further information.)

* - `ode45`
- `integrate.solve_ivp(f)`
- `integrate.solve_ivp(f, t_span, y0)`
- integrate an ODE with Runge-Kutta 4,5

* - `ode15s`
- `integrate.solve_ivp(f, method='BDF')`
- `integrate.solve_ivp(f, t_span, y0, method='BDF')`
- integrate an ODE with BDF method
````

Expand Down Expand Up @@ -387,7 +387,7 @@ arguments are two-dimensional entities.
rng = default_rng(42)
rng.random((3, 4))
```
or older version: `random.rand((3, 4))`
or older version: `np.random.rand(3, 4)`

- generate a random 3x4 array with default random number generator and
seed = 42
Expand All @@ -397,11 +397,11 @@ arguments are two-dimensional entities.
- 4 equally spaced samples between 1 and 3, inclusive

* - `[x,y]=meshgrid(0:8,0:5)`
- `np.mgrid[0:9.,0:6.]` or `np.meshgrid(r_[0:9.],r_[0:6.])`
- `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

* -
- `ogrid[0:9.,0:6.]` or `np.ix_(np.r_[0:9.],np.r_[0:6.]`
- `np.ogrid[0:9.,0:6.]` or `np.ix_(np.r_[0:9.],np.r_[0:6.])`
- the best way to eval functions on a grid

* - `[x,y]=meshgrid([1,2,4],[2,4,5])`
Expand Down Expand Up @@ -448,7 +448,7 @@ arguments are two-dimensional entities.
- L2 norm of vector `v`

* - `a & b`
- `logical_and(a,b)`
- `np.logical_and(a,b)`
- element-by-element AND operator (NumPy ufunc) [See note LOGICOPS](#notes)

* - `a | b`
Expand Down Expand Up @@ -476,12 +476,12 @@ arguments are two-dimensional entities.
- matrix rank of a 2D array `a`

* - `a\b`
- `linalg.solve(a, b)` if `a` is square; `linalg.lstsq(a, b)`
- `linalg.solve(a, b)` if `a` is square; `linalg.lstsq(a, b)[0]`
otherwise
- solution of a x = b for x

* - `b/a`
- Solve `a.T x.T = b.T` instead
- Solve `a.T x.T = b.T` instead: `linalg.solve(a.T, b.T).T`
- solution of x a = b for x

* - `[U,S,V]=svd(a)`
Expand All @@ -508,7 +508,7 @@ arguments are two-dimensional entities.
- find the `k=3` largest eigenvalues and eigenvectors of 2D array, `a`

* - `[Q,R]=qr(a,0)`
- `Q,R = linalg.qr(a)`
- `Q,R = linalg.qr(a, mode='economic')`
- QR decomposition

* - `[L,U,P]=lu(a)` where `a==P'*L*U`
Expand All @@ -529,7 +529,7 @@ arguments are two-dimensional entities.
- inverse Fourier transform of `a`

* - `sort(a)`
- `np.sort(a)` or `a.sort(axis=0)`
- `np.sort(a, axis=0)` or `a.sort(axis=0)`
- sort each column of a 2D array, `a`

* - `sort(a, 2)`
Expand All @@ -541,11 +541,11 @@ arguments are two-dimensional entities.
- save the array `a` as array `b` with rows sorted by the first column

* - `x = Z\y`
- `x = linalg.lstsq(Z, y)`
- `x = linalg.lstsq(Z, y)[0]`
- perform a linear regression of the form $\mathbf{Zx}=\mathbf{y}$

* - `decimate(x, q)`
- `signal.resample(x, np.ceil(len(x)/q))`
- `signal.resample(x, int(np.ceil(len(x)/q)))`
- downsample with low-pass filtering

* - `unique(a)`
Expand Down
Loading