找回密码
 注册
LabVIEW+单片机学习套件全套教程资料下载[免费]LabVIEW论坛精华列表贴USB0816数据采集卡《LabVIEW宝典》
LabWindows/CVI论坛精华贴NET0816以太网数据采集卡RC0210远程设备授权系统 关闭关停锁定打开设备 户外分布式数据采集
NET1624低速高精度以太网数据采集卡WIFI0824SD无线WIFI网络数据采集卡脱机运行 SD存储 小尺寸微型 串口采集远程采集 安卓 手持移动采集 纪录仪
查看: 11681|回复: 11

如何在matlab中生成dll文件供labview调用

[复制链接]
发表于 2007-11-1 12:25:57 | 显示全部楼层 |阅读模式
急用啊!有详细的步骤提供一下!
发表于 2007-11-1 13:24:16 | 显示全部楼层
网上找下学习资料吧
MATLAB6.5应用接口编程
里面有讲,你可以搜一下
回复 顶

使用道具 举报

发表于 2007-11-1 15:02:36 | 显示全部楼层
matlab下生成的dll实际上还是com控件,可以自动生成注册文件,运行即可注册。我实际使用了,发现存在2个问题:
1、速度很慢;
2、数组类型不工作;只可以在参数为数字时候正确。
2006a版本以前可以输入comtool,即可。
在2006a版本以后,就是输入:dotnettool,然后弹出一个对话框的生成东西,只要简单的配置,就可以了,或者在matlab的帮助文件里面输入dotnettool。
回复 顶

使用道具 举报

发表于 2007-11-1 15:04:15 | 显示全部楼层
我做了一个例子,大家可以自己学习学习如何生成,调用的部分labVIEW7.1程序我也附加了一个,里面是2个m文件,一起添加进去,build成com即可。
在C盘放上一个图片为: 1.jpg 即可
请看效果图。

[ 本帖最后由 wdyjz 于 2007-11-1 15:07 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 顶

使用道具 举报

 楼主| 发表于 2007-11-1 19:22:44 | 显示全部楼层
  thanks  for everyone^^

不过我不知道为什么在自己的机子上写个简单的m都没办法生成build com 老是提示出错!
对matlab不熟啊!能有个图解就好了!呵呵
回复 顶

使用道具 举报

 楼主| 发表于 2007-11-1 19:27:01 | 显示全部楼层
wdyjz兄如果不嫌麻烦的话  做个matlab生成dll的详细步骤图解  教教我们这些菜鸟吧~~
回复 顶

使用道具 举报

发表于 2007-11-1 23:29:11 | 显示全部楼层
好的。明天我有时间搞一个,让兄弟们看看。不过别人做的有现成的,写的有现成的文章,还是看别人的吧。
http://blog.csdn.net/yuanqingfei/archive/2004/07/04/33519.aspx
matlab7.0以前输入:comtool
2006a开始:donnettool
最好安装visual studio .net2003或者其后面的更新版本。

[ 本帖最后由 wdyjz 于 2007-11-2 10:14 编辑 ]
回复 顶

使用道具 举报

 楼主| 发表于 2007-11-3 12:30:34 | 显示全部楼层
Building standalone executable...
mcc -M -silentsetup -d 'C:/MATLAB6p5/work/src'  -B 'csglcom:comtest,sgltest,1.0'  -i C:/MATLAB6p5/work/im_test.m C:/MATLAB6p5/work/split2rgb.m   

  MBUILD.BAT: Error: The chosen compiler does not support building COM objects.
        Please see the MATLAB Add-in for Excel documentation for the latest list of supported compilers.


wdyjz兄 这是怎么一会事??帮我解答下哦!

[ 本帖最后由 shihuangjj 于 2007-11-3 12:31 编辑 ]
回复 顶

使用道具 举报

发表于 2007-11-3 14:02:59 | 显示全部楼层
最好安装visual studio .net2003或者其后面的更新版本。
设置下编译器,里面有个命令的。

[ 本帖最后由 wdyjz 于 2007-11-3 14:06 编辑 ]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
回复 顶

使用道具 举报

发表于 2007-11-3 14:12:14 | 显示全部楼层
>> mbuild -setup
Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? y

Select a compiler:
[1] Lcc C version 2.4.1 in C:\PROGRAM FILES\MATLAB\R2006A\sys\lcc
[2] Microsoft Visual C/C++ version 8.0 in D:\Program Files\Microsoft Visual Studio 8
[3] Microsoft Visual C/C++ version 7.1 in C:\Program Files\Microsoft Visual Studio .NET 2003
[4] Microsoft Visual C/C++ version 6.0 in D:\Program Files\Microsoft Visual Studio

[0] None

Compiler: 2

Please verify your choices:

Compiler: Microsoft Visual C/C++ 8.0
Location: D:\Program Files\Microsoft Visual Studio 8

Are these correct?([y]/n): y

****************************************************************************
  Warning: Applications/components generated using Microsoft Visual Studio   
           2005 require that the Microsoft Visual Studio 2005 run-time      
           libraries be available on the computer used for deployment.      
           To redistribute your applications/components, be sure that the   
           deployment machine has these run-time libraries. More information
           is at:                                                            
           http://www.mathworks.com/support/solutions/data/1-2223MW.html     
****************************************************************************

Trying to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R2006a\compopts.bat
From template:              C:\PROGRAM FILES\MATLAB\R2006A\BIN\win32\mbuildopts\msvc80compp.bat

Done . . .


--> ""C:\Program Files\MATLAB\R2006a\bin\win32\mwregsvr" "C:\Program Files\MATLAB\R2006a\bin\win32\mwcomutil.dll""

DllRegisterServer in C:\Program Files\MATLAB\R2006a\bin\win32\mwcomutil.dll succeeded

--> ""C:\Program Files\MATLAB\R2006a\bin\win32\mwregsvr" "C:\Program Files\MATLAB\R2006a\bin\win32\mwcommgr.dll""

DllRegisterServer in C:\Program Files\MATLAB\R2006a\bin\win32\mwcommgr.dll succeeded

>>
回复 顶

使用道具 举报

发表于 2007-11-3 14:12:59 | 显示全部楼层
Building a Deployable Application


The steps to create a COM component are very similar to the steps described in How to Create a .NET Component. Here is a brief summary of the steps:

If you have not already done so, execute the following command in MATLAB:
mbuild -setup



Be sure to choose a supported compiler. See Compiler Requirements.

Type dotnettool at the command line in MATLAB to open the MATLAB Builder dialog box.

Click File > New > Project to open the New Project Settings dialog box.

Specify names for the component and at least one class that will be part of the component.

Accept the current settings by clicking OK.

.NET Builder creates and saves a project file named component_name.cbl in the project directory.

The project file is part of your project workspace. It contains the names of any M-files or MEX-files you subsequently add to the project. Adding these files is the next step.

Click Add File to add methods to the component classes.

Click Build > COM Object to build the project.

The build process sends intermediate source files to the \src sub-directory and output files necessary for deployment to the \distrib sub-directory of your project directory. The files in \distrib are DLLs, which are automatically registered on your system.

You probably want to test your component before packaging, which is the next step. After testing the component outside of the MATLAB environment you can reopen the project and proceed to the next step.

Click Component > Package Component to create a self-extracting executable. .NET Builder names this file componentname.exe.



Files in the self-extracting executable


FilePurposecomponentname.ctf

Component Technology File (ctf) archive. This is a platform-dependent file that must correspond to the end user's platform.componentname_projectversion

Component that encapsulates M-code_install.bat

Script run by the self-extracting executableMCRInstaller.exe

Self-extracting MATLAB Component Runtime library utility; platform-dependent file that must correspond to the end user's platform.

MCRInstaller.exe installs MATLAB Component Runtime (MCR), which users of your component need to install on the target machine once per release.




Distribute the self-extracting executable to your users.
回复 顶

使用道具 举报

xingkong432 该用户已被删除
发表于 2009-9-15 16:57:25 | 显示全部楼层
回复 顶

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cpubbs论坛. ( 粤ICP备09171248号 )

GMT+8, 2026-9-28 07:07 , Processed in 0.054732 second(s), 15 queries , Gzip On, File On.

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表