Calling matlab function from VisualStudio C#

Hi everybody, I need your help!!
MATLAB FUNCTION (R2018a)
function Result = FunSum(a,b)
Result = a+b;
end
My code in Visual Studio 2017, in a Windows Form project is:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SumApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnSum_Click(object sender, EventArgs e)
{
double A = Convert.ToDouble(txtA.Text);
double B = Convert.ToDouble(txtB.Text);
MLApp.MLApp matlab = new MLApp.MLApp();
matlab.Execute(@"cd c:\FunSum");
object result = null;
matlab.Feval("FunSum", 1, out result, A, B);
object[] res = result as object[];
txtR.Text = Convert.ToString(res[0]);
}
}
}
..now, friends, the error that i see is:
System.Runtime.InteropServices.COMException: 'Undefined function 'FunSum' for input arguments of type 'double'.'
but, this is not true, because the code sometimes has worked!!! anyone of you could help me?
thanks

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Programming 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by