matlab_data_processor module¶
Definition of Matlab data processor.
Overview¶
The class and functions in this module enables to manipulate data from and toward the Matlab workspace. It also enables to read and write Matlab data file (.mat).
- class gemseo_matlab.matlab_data_processor.MatlabDataProcessor[source]
Bases:
DataProcessor
A Matlab data processor.
Convert GEMSEO format to Matlab format.
Examples
>>> # Build a new instance >>> proc = MatlabDataProcessor() >>> # initial python data >>> d = {"x": array([2]), "y": array([2j], dtype="complex")} >>> # process data to matlab format >>> res = proc.pre_process_data(d) >>> print(res) >>> >>> # initial data in matlab format >>> d = {"y": double([2, 3]), "x": double([2j], is_complex=True)} >>> # process to Python format >>> res = proc.post_process_data(d) >>> print(res)
- post_process_data(data)[source]
Transform the output data from Matlab to GEMSEO.
- gemseo_matlab.matlab_data_processor.array2double(data_array)[source]
Convert a ndarray into a matlab.double.
May lead to memory leaks for matlabengine < 9.12.
- Parameters:
data_array (ndarray) – The numpy array to be converted.
- Returns:
The matlab.double value.
- Return type:
matlab.double
- gemseo_matlab.matlab_data_processor.convert_array_from_matlab(data)[source]
Convert dict of matlab.output to dict of ndarray.
- gemseo_matlab.matlab_data_processor.convert_array_to_matlab(data)[source]
Convert gems dict of ndarray to dict of matlab.double.
- gemseo_matlab.matlab_data_processor.double2array(matlab_double)[source]
Turn a matlab double into ndarray.
- Parameters:
matlab_double (matlab.double) – The matlab.double values.
- Returns:
The array of values.
- Return type:
- gemseo_matlab.matlab_data_processor.load_matlab_file(file_path)[source]
Read .mat file and convert it to usable format for Matlab.
- gemseo_matlab.matlab_data_processor.save_matlab_file(data, file_path='output_dict', **options)[source]
Save data to a MATLAB-style .mat file.
- Parameters:
- Raises:
ValueError – If some values in
data
are not NumPy arrays.- Return type:
None