Consider the following Matlab code:
pmod(1).name{1} = \'regressor1\';
pmod(1).param{1} = [1 2 4 5 6];
pmod(1).poly{1} = 1;
pmod(2).name{1} = \'regressor2-
You can use np.core.records.fromarrays
to construct a record array, which is roughly equivalent to a MATLAB struct, and will be converted to a MATLAB struct by scip.io.savemat
.
from numpy.core.records import fromarrays
from scipy.io import savemat
myrec = fromarrays([[1, 10], [2, 20]], names=['field1', 'field2'])
savemat('p.mat', {'myrec': myrec})
When opened in MATLAB, this gives:
>> load('p.mat')
>> myrec
myrec =
1x2 struct array with fields:
field1
field2