Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
![]() |
#1 |
初级会员
注册日期: 2008-04-30
年龄: 25
帖子: 1
声望力: 0 ![]() |
![]()
关于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: |
![]() |
![]() |
![]() |
#2 |
初级会员
注册日期: 2008-05-13
年龄: 41
帖子: 5
声望力: 0 ![]() |
![]()
看不太懂,可能很简单吧,呵呵,请楼主细心的讲解一下吧
|
![]() |
![]() |
![]() |
#3 |
初级会员
注册日期: 2008-06-17
年龄: 37
帖子: 4
声望力: 0 ![]() |
![]()
没有using MathWorks.Matlab........
没有using你生成的dll的namespace 这些都需要手工加到工程的reference中并写上using的 |
![]() |
![]() |
![]() |
#4 |
初级会员
注册日期: 2008-05-12
年龄: 39
帖子: 4
声望力: 0 ![]() |
![]()
请问你的dll文件是怎么注册的 我为什么注册的时候出现问题:已加载,但是没有找到输入点呢?
|
![]() |
![]() |
![]() |
#5 |
初级会员
注册日期: 2008-06-17
年龄: 37
帖子: 4
声望力: 0 ![]() |
![]()
我的做法是:
1. 在matlab中用matlab builder把.m文件编译为.net assembly 2. 在vs中添加路径,使得mathworks这个namespace可以被reference到,以便使用matlab中的数组类 3. 在工程中添加到mathworks和第1步生成的assembly的reference 然后就可以用了 你的问题描述得不是很清楚 我觉得其实你查一查matlab的帮助文件,按照getting started讲的步骤,就能让程序正常跑起来 |
![]() |
![]() |
![]() |
|
|
![]() |
||||
主题 | 主题作者 | 版面 | 回复 | 最后发表 |
[求助]一个GUI的问题,制作的界面怎样定位在屏幕中间? | wwww1031 | MATLAB论坛 | 8 | 2008-08-28 22:52 |
[求助]请问在simulink中怎么表示这个函数?急! | cumtwwww | MATLAB论坛 | 10 | 2008-05-12 17:31 |
曲线的拟合 | cherybmw | MATLAB论坛 | 0 | 2008-05-06 14:24 |
[求助]不规则网格上的数据怎么用图像表示?谢谢 | waterrock | MATLAB论坛 | 1 | 2008-04-18 19:29 |
[求助]删除矩阵行的函数 | joyht | MATLAB论坛 | 4 | 2008-04-16 16:02 |