查看单个帖子
旧 2008-05-07, 21:09   #1
kk20021055
初级会员
 
注册日期: 2008-04-30
年龄: 25
帖子: 1
声望力: 0
kk20021055 正向着好的方向发展
默认 [求助]关于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);
}

}
}
}

:redface: :redface: :redface: :redface: :redface:
kk20021055 当前离线   回复时引用此帖