云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 关于matlab与c#混合编程的问题

关于matlab与c#混合编程的问题

  • 62 次阅读
  • 3 次下载
  • 2025/5/6 13:42:13

是“项目名称Native.dll”,这2个dll的差别可以通过\文件夹源码来观察。“distrib”就是源代码的文件夹。如下图所示,src文件夹的文件示意图:

我们2.2中新建的类名是TestDemo,所以生成的的源码名称也是TestDemo,看看这2个cs文件中的代码,同时类的方法也可以在VS中通过对象浏览器来查看dll有哪些方法以及方法的参数类型。直接贴这2个cs文件的代码,顺便解释和对比下: TestDemo.cs文件源码:

1/*

2* MATLAB Compiler: 4.17 (R2012a) 3* Date: Mon Sep 09 16:19:01 2013

4* Arguments: \\ 5* \

\

6* \ 7* \\ 8* \

\\ 9*/

10using System;

11using System.Reflection;

12using System.IO;

13using MathWorks.MATLAB.NET.Arrays; 14using MathWorks.MATLAB.NET.Utility; 15

16#if SHARED

17 [assembly: System.Reflection.AssemblyKeyFile(@\)] 18#endif 19

20namespace PlotTest 21 { 22

23///

24/// The TestDemo class provides a CLS compliant, MWArray interface to the M-functions

25/// contained in the files: 26///

27/// D:\\Work\\DevelopMent_SVN\\Matlab\\MatlabBlog\\PlotTest.m 28/// 29/// deployprint.m

30/// 31/// printdlg.m 32///

33///

34/// @Version 0.0 35///

36publicclass TestDemo : IDisposable 37 {

38#region Constructors 39

40///

41/// The static constructor instantiates and initializes the MATLAB Compiler Runtime 42/// instance. 43///

44static TestDemo() 45 {

46if (MWMCR.MCRAppInitialized) 47 {

48 Assembly assembly= Assembly.GetExecutingAssembly(); 49

50string ctfFilePath= assembly.Location; 51

52int lastDelimiter= ctfFilePath.LastIndexOf(@\); 53

54 ctfFilePath= ctfFilePath.Remove(lastDelimiter, (ctfFilePath.Length - lastDelimiter)); 55

56string ctfFileName = \; 57

58 Stream embeddedCtfStream = null; 59

60 String[] resourceStrings = assembly.GetManifestResourceNames(); 61

62foreach (String name in resourceStrings) 63 {

64if (name.Contains(ctfFileName)) 65 {

66 embeddedCtfStream =

assembly.GetManifestResourceStream(name); 67break;

68 } 69 }

70 mcr= new MWMCR(\,

71 ctfFilePath, embeddedCtfStream, true); 72 } 73else 74 {

75thrownew ApplicationException(\initialized\); 76 } 77 } 78 79

80///

81/// Constructs a new instance of the TestDemo class. 82///

83public TestDemo() 84 { 85 } 86 87

88#endregion Constructors 89

90#region Finalize 91

92///

93/// Class destructor called by the CLR garbage collector.

94///

95 ~TestDemo() 96 {

97 Dispose(false); 98 } 99 100

101///

102/// Frees the native resources associated with this object 103///

104publicvoid Dispose() 105 {

106 Dispose(true); 107

108 GC.SuppressFinalize(this); 109 } 110 111

112///

115protectedvirtualvoid Dispose(bool disposing) 116 {

117if (!disposed) 118 {

119 disposed= true; 120

121if (disposing) 122 {

123// Free managed resources; 124 } 125

126// Free native resources 127 } 128 } 129 130

131#endregion Finalize 132

133#region Methods 134

135///

136/// Provides a void output, 0-input MWArrayinterface to the PlotTest M-function.

搜索更多关于: 关于matlab与c#混合编程的问题 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

是“项目名称Native.dll”,这2个dll的差别可以通过\文件夹源码来观察。“distrib”就是源代码的文件夹。如下图所示,src文件夹的文件示意图: 我们2.2中新建的类名是TestDemo,所以生成的的源码名称也是TestDemo,看看这2个cs文件中的代码,同时类的方法也可以在VS中通过对象浏览器来查看dll有哪些方法以及方法的参数类型。直接贴这2个cs文件的代码,顺便解释和对比下: TestDemo.cs文件源码: 1/* 2* MATLAB Compiler: 4.17 (R2012a) 3* Date: Mon Sep 09 16:19:01 2013 4* Arguments: \\ 5* \\ 6* \ 7* \\ 8*

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com