Exemplo n.º 1
0
 public static void KillMatlab()
 {
     try
     {
         matlab.Quit();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 2
0
        public static object GenerateMatrixH(int Size)
        {
            MLApp.MLApp matlab = new MLApp.MLApp();

            matlab.Execute(@"cd C:\Users\Nekoszi");

            object result = null;

            matlab.Feval("GenerateMatrixH", 1, out result, Size);

            matlab.Quit();

            object[] res = result as object[];
            return(res[0]);
        }
Exemplo n.º 3
0
 private void proc()
 {
     MLApp.MLApp Call_Matlab = new MLApp.MLApp();
     Call_Matlab.Visible = 0;
     object result = null;
     Call_Matlab.Execute(@"cd C:\MatlabProcessing");
     try
     {
         Call_Matlab.Feval("MAIN_PROCESSING", 1, out result, PthTs, PthTr, PthAl);
         Res = result as object[];
         MessageBox.Show(Res[0].ToString());
         Call_Matlab.Quit();
         Marshal.ReleaseComObject(Call_Matlab);
     }
     catch (Exception e)
     {
         Marshal.ReleaseComObject(Call_Matlab);
         MessageBox.Show(e.ToString());
     }
 }
Exemplo n.º 4
0
        private void proc()
        {
            MLApp.MLApp Call_Matlab = new MLApp.MLApp();
            Call_Matlab.Visible = 0;
            object result = null;

            Call_Matlab.Execute(@"cd C:\MatlabProcessing");
            try
            {
                Call_Matlab.Feval("MAIN_PROCESSING", 1, out result, PthTs, PthTr, PthAl);
                Res = result as object[];
                MessageBox.Show(Res[0].ToString());
                Call_Matlab.Quit();
                Marshal.ReleaseComObject(Call_Matlab);
            }
            catch (Exception e)
            {
                Marshal.ReleaseComObject(Call_Matlab);
                MessageBox.Show(e.ToString());
            }
        }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     matlab.Quit();
 }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     matlab.Quit();
     arimaLogger.Flush();
     arimaLogger.Close();
 }
Exemplo n.º 7
0
        public static double[][] getTransformedMatrix(double[][] data, double p)
        {
            // MLApp.MLApp matlab = new MLApp.MLApp();
            const string pathToMatlabFolderAmazon = @"cd C:\Users\Administrator\Desktop\AlexDropbox\Dropbox\Alex-Oren\matlabDiffusionMaps\diff_code";
            const string pathToMatlabFolderLocal  = @"cd C:\Users\Alex\Dropbox\Alex-Oren\matlabDiffusionMaps\diff_code";
            const string checkAmazonFolderExist   = "C:\\Users\\Administrator\\Desktop\\AlexDropbox\\Dropbox\\Alex-Oren\\matlabDiffusionMaps\\diff_code";
            string       executePath = (Directory.Exists(checkAmazonFolderExist))
                ? pathToMatlabFolderAmazon
                : pathToMatlabFolderLocal;
            // MLApp.MLApp matlab = new MLApp.MLApp();
            // matlab.Execute(@"cd C:\Users\Alex\Dropbox\Alex-Oren\matlabDiffusionMaps\diff_code");
            // Define the output
            List <string[]> strTransData;

            try
            {
                matlab.Execute(executePath);
                //convert matrix to matlab type string
                string strMat = "[";
                foreach (double[] row in data)
                {
                    strMat  = row.Aggregate(strMat, (current, val) => current + (val.ToString(CultureInfo.InvariantCulture) + ","));
                    strMat  = strMat.Remove(strMat.Length - 1);
                    strMat += ";";
                }
                strMat += "]";
                object res;
                matlab.Feval("sharpCallVisual", 1, out res, strMat, p);

                ArrayList a = new ArrayList((object[])res);
                //can't calcualate eigenvectors
                if (a[0].ToString() == "-1")
                {
                    return(null);
                }

                string[] prepareResult = ((string)a[0]).Split('\n');

                List <string> strList = new List <string>(prepareResult);
                strList.ForEach(s => { if (s.Length == 0)
                                       {
                                           strList.Remove(s);
                                       }
                                });
                strTransData = strList.ConvertAll(s => prepareMatlabStr(s).Split('\t'));
            }
            catch (Exception)
            {
                return(null);
            }

            double[][] transformedData;
            try
            {
                transformedData = strTransData.ConvertAll(s => Array.ConvertAll(s, Double.Parse)).ToArray();
            }
            catch (Exception)
            {
                throw new Exception("DiffusionMaps convert transformed data error!!!");
            }
            matlab.Execute("clear;");
            matlab.Quit();

            return(transformedData);
        }
Exemplo n.º 8
0
 public void Quit()
 {
     _matlabInstance.Quit();
     _matlabInstance = null;
 }