pyphysim.extra.MATLAB package¶
Submodules¶
pyphysim.extra.MATLAB.python2MATLAB module¶
Module with functions to easily moving data from python to MATLAB.
-
pyphysim.extra.MATLAB.python2MATLAB.
to_mat_str
(x, format_string='+.12e')[source]¶ Convert the ndarray ‘x’ to a string corresponding to the MATLAB representation of x.
The to_mat_str function formats numpy arrays of arbitrary dimension in a way which can easily copied and pasted into an interactive MATLAB session
- Parameters
x (numpy array) – The numpy array to be represented as a MATLAB type.
format_string (str, optional) – The format_string string to convert each element in x.
- Returns
converted_string – A string that represents the converted numpy array. You can copy this string and past it into a MATLAB session.
- Return type
Examples
>>> a=np.arange(1,10) >>> a.shape=(3,3) >>> # Print as a numpy matrix >>> print(a) [[1 2 3] [4 5 6] [7 8 9]] >>> # Call to_mat_str(a) to print the string representation of the >>> # converted matrix >>> print(to_mat_str(a)) [+1.000000000000e+00, +2.000000000000e+00, +3.000000000000e+00; +4.000000000000e+00, +5.000000000000e+00, +6.000000000000e+00; +7.000000000000e+00, +8.000000000000e+00, +9.000000000000e+00]
Module contents¶
Package with MATLAB related functions.
Examples: conversions for the print output from python to MATLAB and vice-verse. That way you can print a numpy array, copy the output and past in MATLAB for further analysis.