c# - 从 Matlab 到 C# 的输出参数太多
问题描述
我正在从 C# 应用程序运行 Matlab 函数。我希望我的 Matlab 函数向我的 c# 应用程序返回一个值。
但是我收到下面的错误消息。我很困惑,因为我只期待一个值,所以不知道为什么这个错误消息告诉我?
使用 someFunction 时出错 输出参数过多。
MATLAB
function [success] = autoRun_someFunction
try
someFunction;
success = 1;
catch ME
success = getReport(ME, 'extended');
end
C#
FunctionName = "autoRun_someFunction";
public string RunMatlabScriptResult(string FunctionDirectory, string FunctionName)
{
// create matlab instance
_matlab = new MLApp.MLApp();
// change to the directory where the function is located
string pathChecker = @"C:\MyFolder\";
_matlab.Execute(@"cd " + pathChecker);
// call the matlab is checking the search path
object resultChk = null;
_matlab.Feval("check_path", 0, out resultChk);
// change to the directory where the function is located
_matlab.Execute(@"cd " + FunctionDirectory);
// define the output
object result = null;
// call the matlab function upload_data
_matlab.Feval(FunctionName, 1, out result);
// quit matlab
_matlab.Quit();
// display result
object[] res = result as object[];
return res[0].ToString();
}
解决方案
推荐阅读
- java - Logback RollingFileAppender 文件属性无法识别 springProperty 值
- php - Laravel Voyager:翻译不适用于帖子和页面
- python-3.x - 对 peewee 字段类型进行子类化以添加行为
- github - 我在github项目中添加了很多行,为什么说我只添加了两个?
- python - Pandas groupby.size vs series.value_counts vs collections.Counter与多个系列
- php - Laravel 5.5 HasManyThrough 关系
- azure - 如何在 Azure 中的应用服务之间共享应用程序设置?
- twig - 使用 CodeIgniter 设置 Twig 时出错
- android - 回收站视图未在三星 S8 中显示项目
- bash - Shell 脚本循环是/否