关于matlab与c#混合编程的问题(6)
177return mcr.EvaluateFunction(numArgsOut, \, new MWArray[]{}); 178 } 179 180
181///
182/// Provides the standard 1-input MWArray interface to the PlotTest M-function.
183/// 184///
185/// M-Documentation:
186/// 编写一个简单的函数,对plot进行简单封装一下 187///
188///
189///
190///
193public MWArray[] PlotTest(int numArgsOut, MWArray n) 194 {
195return mcr.EvaluateFunction(numArgsOut, \, n); 196 } 197 198 199
200///
201/// This method will cause a MATLAB figure window to behave as a modal dialog box.
202/// The method will not return until all the figure windows associated with this
203/// component have been closed. 204/// 205///
206/// An application should only call this method when required to keep the
207/// MATLAB figure window from disappearing. Other techniques, such as calling 208/// Console.ReadLine() from the application should be considered where 209/// possible. 210///
211publicvoid WaitForFiguresToDie() 212 {
213 mcr.WaitForFiguresToDie();
214 } 215 216 217
218#endregion Methods 219
220#region Class Members 221
222privatestatic MWMCR mcr= null; 223
224privatebool disposed= false; 225
226#endregion Class Members 227 } 228 }
TestDemoNative.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 PlotTestNative 21 { 22
23///
24/// The TestDemo class provides a CLS compliant, Object (native) interface to the
25/// M-functions contained in the files: 26///
27/// D:\\Work\\DevelopMent_SVN\\Matlab\\MatlabBlog\\PlotTest.m 28///
30///
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///
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 Objectinterface to the PlotTest M-function.
137/// 138///
139/// M-Documentation:
140/// 编写一个简单的函数,对plot进行简单封装一下 141/// 142///
143publicvoid PlotTest()
…… 此处隐藏:1733字,全部文档内容请下载后查看。喜欢就下载吧 ……相关推荐:
- [政务民生]2013年公共基础知识热点问题(七)
- [政务民生]检验检测机构资质认定评审准则及释义20
- [政务民生]关于印发重庆市房屋建筑和市政基础设施
- [政务民生]1、隧道洞身开挖支护施工技术交底书
- [政务民生]2015年山东省17地市中考语文试题分类汇
- [政务民生]2-高级会计师资格考试和评审流程图
- [政务民生]2018版中国清分机行业发展分析及前景策
- [政务民生]新课改高中政治探究
- [政务民生]2018-2024年中国新型组合房屋行业投资
- [政务民生]2015年上海市春季高考数学模拟试卷五
- [政务民生]灌砂法及环刀法测压实度(带计算过程)
- [政务民生]运筹学实验2求解非线性规划
- [政务民生]劝学、逍遥游默写(教师卷)
- [政务民生]《运筹学》 - 期末考试 - 试卷A - 答案
- [政务民生]八年级英语下册 Module 6 Hobbies测试
- [政务民生]2019年宪法知识竞赛试题库100题(含答
- [政务民生]自动化英文文献翻译
- [政务民生]公文格式实施细则
- [政务民生]高一地理上册课堂跟踪练习题6
- [政务民生]会计继续教育习题及答案
- 第三章 无约束最优化方法
- 泛读教程第三册答案
- 魏晋南北朝文学
- 幂的运算复习题
- 城市环境问题的成因与治理策略_以社会
- 钢结构行业产业链及竞争分析研究
- 新型热塑性弹性体增韧聚丙烯的研究
- 中国旅游地理B卷试题及答案
- (苏教版)五年级数学上册第三单元测试卷
- 不稳定性心绞痛诊断与治疗
- 俞氏国际后勤职能部门绩效考核办法
- GB7258-2017新标准考试题含答案
- 小学生汉字听写比赛活动方案
- 1.3《平抛运动》学案 教科版必修2
- 2011香港特别行政区公务员考试复习资料
- 考虑水力条件变化的城市给水管网可靠性
- 表面活性剂在油田开发和生产中的应用
- ITT内部培训资料-FI端吸泵的介绍
- 文明守纪,从我做起学生发言稿
- 初中读《聊斋志异》心得体会800字范文