Calling matlab function from VisualStudio C#
Afficher commentaires plus anciens
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
1 commentaire
Nguyen
le 12 Juin 2021
Hello,
Does your code work now?
I have the same error.
Réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!