通过matlab com自动化服务将数组从matlab传递到c#
我尝试使用通过matlab com自动化服务将数组从matlab传递到c#,c#,matlab,matrix,C#,Matlab,Matrix,我尝试使用PutFullMatrix()&GetFullMatrix()从C#code(.NET)调用一些Matlab函数 我发现它可以很好地将数组传递给Matlab函数,并在Matlab文件中完成计算 当返回值为标量(即1*1矩阵)时,matlab文件还可以将正确答案返回到C#。但当我试图将1*n矩阵从Matlab返回到C#时,它总是在Visual studio中出现异常。它是mscorlib.dll中的“System.Runtime.InteroServices.COMException”类
PutFullMatrix()
&GetFullMatrix()
从C#code(.NET
)调用一些Matlab函数
我发现它可以很好地将数组传递给Matlab函数,并在Matlab文件中完成计算
当返回值为标量(即1*1矩阵)时,matlab文件还可以将正确答案返回到C#。但当我试图将1*n矩阵从Matlab返回到C#时,它总是在Visual studio中出现异常。它是mscorlib.dll中的“System.Runtime.InteroServices.COMException”类型
我试图将函数简化为矩阵加法,但仍然没有成功。有人能解释为什么这失败了吗?我正在为x86CPU使用.NET4.5运行时目标
下面是我有问题的C#代码:
//通过com实例化MATLAB引擎接口
MLApp.MLApp matlab = new MLApp.MLApp();
matlab.PutFullMatrix("basebandData", "base", IData, QData);
matlab.PutFullMatrix("sample_rate", "base", SampleRateR,SampleRateI);
// Using Engine Interface, execute the ML command
// contained in quotes.
matlab.Execute("cd c:\\Users\\****\\Desktop\\MatlabFunctionfolder;");
matlab.Execute("open MATLABFunction.m");
matlab.Execute("dbstop in MATLABFunction.m");
matlab.Execute("[RespRate, HeartRate, HRWav, status]=MATLABFunction(basebandData,sample_rate);");
// matlab.Execute("com.mathworks.mlservices.MLEditorServices.closeAll");
matlab.GetFullMatrix("RespRate", "base", ref RespRateR, ref RespRateI);
matlab.GetFullMatrix("HeartRate", "base", ref HeartRateR, ref HeartRateI);
matlab.GetFullMatrix("HRWav", "base", ref HRWavR,ref HRWavI); // the line where the exception pop up, if don't try to return the array HRWav from matlab function (RespRate, HeartRate, and Status are all 1x1 matrices) the code services well.
matlab.GetFullMatrix("status", "base", ref StatusR, ref StatusI);
Visual Studio正在引发什么异常?COMException:mscorlib.dll中的“System.Runtime.InteroServices.COMException”类型。我正在为x86 CPUI使用.NET 4.5运行时目标。如果问题仍然存在,如何定义
StausR
等?