public void TestPutObject_ValidArgs() { string workspaceName = "Base"; MLAppClass app = MatlabTestInstance.Instance; MatlabSession session = new MatlabSession(app); Workspace space = new Workspace(session, workspaceName); space.PutObject("Obj", new object()); string output = app.Execute("exist Obj"); Debug.Write(output); }
public void TestGetVariable_Set() { string workspaceName = "base"; MLAppClass app = MatlabTestInstance.Instance; MatlabSession session = new MatlabSession(app); Workspace space = new Workspace(session, workspaceName); space.PutObject("a", 1d); app.Execute("b=a*2"); object output = space.GetVariable("b"); Assert.IsNotNull(output); Assert.AreEqual(2d, output); }
public double[,] ExeAlgorithm3(double[] inputData, string algType) { MLAppClass matlab2 = new MLAppClass(); double[,] outputData = new double[inputData.Length, 1]; if (algType == "dbp") { matlab2.PutWorkspaceData("n1", "base", inputData); matlab2.Execute("n2=funBP(n1)"); var n = matlab2.GetVariable("n2", "base"); outputData = (double[,])n; } return outputData; }
public double[,] ExeAlgorithm(double[] inputData, string algType) { MLAppClass matlab1 = new MLAppClass(); double[,] outputData = new double[inputData.Length, 1]; if (algType == "bp") { matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=funBP(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[, ])b; } return(outputData); }
public double[,] ExeAlgorithm3(double[] inputData, string algType) { MLAppClass matlab2 = new MLAppClass(); double[,] outputData = new double[inputData.Length, 1]; if (algType == "dbp") { matlab2.PutWorkspaceData("n1", "base", inputData); matlab2.Execute("n2=funBP(n1)"); var n = matlab2.GetVariable("n2", "base"); outputData = (double[, ])n; } return(outputData); }
/// <summary> /// 使用matlab库运算矩阵乘法 /// </summary> /// <param name="m"></param> /// <returns></returns> public Matrix MultiplyByMatrix_MATLAB(Matrix m) { MLAppClass matlab = new MLAppClass(); double[,] pia = new double[m.nRows, m.nColumns]; double[,] pib = new double[this.nRows, this.nColumns]; matlab.PutFullMatrix("A", "base", m.Cell, pia); matlab.PutFullMatrix("B", "base", this.Cell, pib); matlab.Execute("C = A*B;"); Matrix result =new Matrix(m.nRows, this.nColumns); System.Array pir = new double[m.nRows,this.nColumns]; System.Array prr = new double[m.nRows, this.nColumns]; matlab.GetFullMatrix("C", "base",ref prr,ref pir); for(int i =0;i<prr.GetLength(0);i++) { for (int j = 0; j < prr.GetLength(1); j++) result.Cell[i, j] = (double)(prr.GetValue(i, j)); } return result; }
public double[,] ExeAlgorithm(string algType, double[] inputData) { MLAppClass matlab1 = new MLAppClass(); double[,] outputData = new double[inputData.Length, 1]; if (algType == "bp") { matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=2*a");//matlab1.Execute("b=funBP(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[, ])b; Console.WriteLine("This is the first algorithm"); foreach (var i in outputData) { Console.Write(i); } } if (algType == "rbf") { matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=4*a");//matlab1.Execute("b=funRBF(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[, ])b; Console.WriteLine("This is the second algorithm"); foreach (var i in outputData) { Console.Write(i); } } if (algType == "multi_regression") { matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=10*a");// matlab1.Execute("b=funMultiRegression(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[, ])b; Console.WriteLine("This is the third algorithm"); foreach (var i in outputData) { Console.Write(i); } } if (algType == "BF_RBF_15") { matlab1.Execute("path(path,'K:\\Users\\kevin\\Desktop\\现有算法\\TestAlg')"); matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=BF_RBF_15()");// matlab1.Execute("b=funMultiRegression(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[, ])b; //Console.WriteLine("This is the third algorithm"); //foreach (var i in outputData) //{ // Console.Write(i); //} } return(outputData); }
public double[,] ExeAlgorithm(string algType, double[] inputData) { MLAppClass matlab1 = new MLAppClass(); double[,] outputData = new double[inputData.Length, 1]; if (algType == "bp") { matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=2*a");//matlab1.Execute("b=funBP(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[,])b; Console.WriteLine("This is the first algorithm"); foreach (var i in outputData) { Console.Write(i); } } if (algType == "rbf") { matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=4*a");//matlab1.Execute("b=funRBF(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[,])b; Console.WriteLine("This is the second algorithm"); foreach (var i in outputData) { Console.Write(i); } } if (algType == "multi_regression") { matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=10*a");// matlab1.Execute("b=funMultiRegression(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[,])b; Console.WriteLine("This is the third algorithm"); foreach (var i in outputData) { Console.Write(i); } } if (algType == "BF_RBF_15") { matlab1.Execute("path(path,'K:\\Users\\kevin\\Desktop\\现有算法\\TestAlg')"); matlab1.PutWorkspaceData("a", "base", inputData); matlab1.Execute("b=BF_RBF_15()");// matlab1.Execute("b=funMultiRegression(a)"); var b = matlab1.GetVariable("b", "base"); outputData = (double[,])b; //Console.WriteLine("This is the third algorithm"); //foreach (var i in outputData) //{ // Console.Write(i); //} } return outputData; }