bundles / scipy latest / scipy / io / matlab / _miobase / matdims
function
scipy.io.matlab._miobase:matdims
Signature
def matdims ( arr , oned_as = column ) Summary
Determine equivalent MATLAB dimensions for given array
Parameters
arr: ndarrayInput array
oned_as: {'column', 'row'}, optionalWhether 1-D arrays are returned as MATLAB row or column matrices. Default is 'column'.
Returns
dims: tupleShape tuple, in the form MATLAB expects it.
Notes
We had to decide what shape a 1 dimensional array would be by default. np.atleast_2d thinks it is a row vector. The default for a vector in MATLAB (e.g., >> 1:12) is a row vector.
Versions of scipy up to and including 0.11 resulted (accidentally) in 1-D arrays being read as column vectors. For the moment, we maintain the same tradition here.
Examples
import numpy as np from scipy.io.matlab._miobase import matdims matdims(np.array(1)) # NumPy scalar matdims(np.array([1])) # 1-D array, 1 element matdims(np.array([1,2])) # 1-D array, 2 elements matdims(np.array([[2],[3]])) # 2-D array, column vector matdims(np.array([[2,3]])) # 2-D array, row vector matdims(np.array([[[2,3]]])) # 3-D array, rowish vector matdims(np.array([])) # empty 1-D array✓
matdims(np.array([[]])) # empty 2-D array matdims(np.array([[[]]])) # empty 3-D array✗
matdims(np.array([1,2]), 'row') # 1-D array, 2 elements
✓matdims(np.array([1,2]), 'bizarre')
✓Aliases
-
scipy.io.matlab._mio4.matdims