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

Risposte (0)

Categorie

Scopri di più su Programming in Centro assistenza e File Exchange

Prodotti

Richiesto:

il 30 Mar 2020

Commentato:

il 12 Giu 2021

Community Treasure Hunt

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

Start Hunting!

Translated by