学习型 ASP/PHP/ASP.NET 主机 30元/年全能 ASP/PHP/ASP.NET 主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付
发新话题
打印

关于C#与MATLAB混合编程的一点问题,请各位高手不吝赐教。

关于C#与MATLAB混合编程的一点问题,请各位高手不吝赐教。

在程序运行之前,我已经将M文件生成了DLL,并且已经注册,在VISUAL STUDIO 中已经注册了该DLL。
在VS 中我的代码是:(用的控制台)  问题是老是提示:Function 'plus' not defined for variables of class 'int32'.
M文件为:求两数的和
function result=add(left,right)
result=left + right;

C#代码:
  using System;
using System.Collections.Generic;
using System.Text;

namespace MATLAB混合编程2
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                addnum.addnumClass f = new addnum.addnumClass(); //注册的M文件所生产的DLL
                object result;
                int left = 3;
                int right = 5;
                result = new Object();
                f.add(1, ref result, left, right);
                int answer = (int)result;
                Console.WriteLine(answer);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

        }
    }
}

TOP

发新话题