COM - Feval() passing a table as a Double[,] is as expected, nonetheless c# Dictionary.ToArray() returns a Double[][] (what is called a jagged array)
    2 次查看(过去 30 天)
  
       显示 更早的评论
    
What would a best practice be in passing a Dictionary like structure into a matlab function such as "cov" using COM's Feval() ... take the below example:
SortedDictionary<DateTime, Double[]> tableTT;
...
matlab.Feval("cov", 1, out result, tableTT.Values.ToArray());
will fail, as ToArray() returns a jagged array. 
Is there a way to avoid using a "conversion" function, such as:
static double[,] ImperativeConvert(double[][] source)
{
    double[,] result = new double[source.Length, source[0].Length];
    for (int i = 0; i < source.Length; i++)
    {
        for (int k = 0; k < source[0].Length; k++)
        {
            result[i, k] = source[i][k];
        }
    }
    return result;
}
to convert the jagged array into a two-dimentional array?
0 个评论
回答(1 个)
  Venkat Siddarth Reddy
      
 2024-5-6
        Hi Andy,
You can call another MATLAB function called reshape, to convert the jagged array into 2D array.
To learn more about it,refer to the following documentation:
I hope this resolves your query, if not please comment down your query.
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

