public void Write(Dictionary <string, List <List <double> > > data, string name) { _DataBuilder = new DataBuilder(); _DataStruct = _DataBuilder.NewStructureArray(new[] { name }, 1); foreach (string var in data.Keys) { List <List <double> > values = data[var]; int n = values.Count; int m = values.Max(c => c.Count); _DataStruct[name, 0] = MatlabUtilities.AddFieldToStructureArray(_DataBuilder, _DataStruct[name, 0], var, 1); (_DataStruct[name, 0] as IStructureArray)[var, 0] = _DataBuilder.NewArray <double>(n, m); IArrayOf <double> array = (IArrayOf <double>)(_DataStruct[name, 0] as IStructureArray)[var, 0]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (values[i] != null && j < values[i].Count) { array[i, j] = values[i][j]; } } } } }
private IStructureArray AddFieldToStructureArray(IArray structureArray, string fieldName, params int[] dimensions) { return(MatlabUtilities.AddFieldToStructureArray(_DataBuilder, structureArray, fieldName, dimensions)); }