Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert object array to double array in c#

Hello recently i am trying get the result using matlab function and matlab function can return double array like image but and then I got that double by object class in C# but I could not convert to double that object class some one could help me

I have solved this problem

        MLApp.MLApp matlab = new MLApp.MLApp();
        matlab.Execute(@"Path");
        object result = null;
        matlab.Feval("RemoveShadow", 1, out result, 12, 13);
        var res = (result as object[]).Select(x => (double[,])x).ToArray();
        object im = res.GetValue(0);
        double[,] d = (double[,])im;

I have solved this problem

like image 628
shraga Avatar asked Mar 10 '15 08:03

shraga


1 Answers

if all are double in object array than, alternative to above answer

double[] resultArray = Array.ConvertAll<object, double>
                                  (inputArray, x => (double)x);
like image 76
Pranay Rana Avatar answered Sep 22 '22 02:09

Pranay Rana