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
댓글 수: 1
Nguyen
2021년 6월 12일
Hello,
Does your code work now?
I have the same error.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!