You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't find a MatFileHandler native way to handle conversion of 2-dimensional jagged arrays into an IArray representing a MATLAB matrix, so I coded this simple extension method that could be added/enhanced/adapted to native MatFileHandler.
It can also be adapted for inputs of type T[,]
public static class MyExtensionMethods
{
public static IArrayOf<T> NewArray<T>(this DataBuilder matDataBuilder, T[][] data, params int[] dimensions)
where T : struct
{
var array = matDataBuilder.NewArray<T>(dimensions);
var m = data.Length;
var n = data[0].Length; // assuming the jagged array represents a 2d matrix; it could be checked though
for (var i = 0; i < m; i++)
{
for (var j = 0; j < n; j++)
{
array[j * m + i] = data[i][j];
}
}
return array;
}
}
The text was updated successfully, but these errors were encountered:
I couldn't find a MatFileHandler native way to handle conversion of 2-dimensional jagged arrays into an IArray representing a MATLAB matrix, so I coded this simple extension method that could be added/enhanced/adapted to native MatFileHandler.
It can also be adapted for inputs of type
T[,]
The text was updated successfully, but these errors were encountered: