C# matlab

编译环境:Microsoft Visual Studio 2008
版本 9.0.21022.8 RTM
Microsoft .NET Framework
版本 3.5
安装的版本: Professional
Microsoft Visual Basic 2008   91986-031-5000002-60050
Microsoft Visual Basic 2008
Microsoft Visual C# 2008   91986-031-5000002-60050
Microsoft Visual C# 2008
Microsoft Visual C++ 2008   91986-031-5000002-60050
Microsoft Visual C++ 2008
Microsoft Visual Studio 2008 Tools for Office   91986-031-5000002-60050
Microsoft Visual Studio 2008 Tools for Office
Microsoft Visual Web Developer 2008   91986-031-5000002-60050
Microsoft Visual Web Developer 2008
Crystal Reports    AAJ6G-K0MSA4K-680002Z
Crystal Reports Basic for Visual Studio 2008

Matlab 2008b
首先需要做的工作是matlab编译器的设置,设置方法为:在Command window中输入mbuild -setup显示如下
>> mbuild -setup
Please choose your compiler for building standalone MATLAB applications:

Would you like mbuild to locate installed compilers [y]/n? n    %选择n
Select a compiler:
[1] Lcc-win32 C 2.4.1
[2] Microsoft Visual C++ 6.0
[3] Microsoft Visual C++ .NET 2003
[4] Microsoft Visual C++ 2005
[5] Microsoft Visual C++ 2005 Express Edition
[6] Microsoft Visual C++ 2008

[0] None
Compiler: 6                             %选择6,其他编译器可以选相应的选项,我没有验证过
The default location for Microsoft Visual C++ 2008 compilers is C:\Program Files\Microsoft Visual Studio 9.0,
but that directory does not exist on this machine.

Use C:\Program Files\Microsoft Visual Studio 9.0 anyway [y]/n? n%选择n
Please enter the location of your compiler: [C:\Program Files\Microsoft Visual Studio 9.0] D:\Program Files\Microsoft Visual Studio 9.0 %选择您自己的当前安装路径
Please verify your choices:

Compiler: Microsoft Visual C++ 2008
Location: D:\Program Files\Microsoft Visual Studio 9.0

Are these correct [y]/n? y  %看上述信息,如果正确选择y
****************************************************************************
  Warning: Applications/components generated using Microsoft Visual Studio  
           2008 require that the Microsoft Visual Studio 2008 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.                 
****************************************************************************

Trying to update options file: C:\Documents and Settings\Administrator\Application Data\MathWorks\MATLAB\R2008b\compopts.bat
From template:              D:\PROGRA~1\MATLAB\R2008b\bin\win32\mbuildopts\msvc90compp.bat

Done . . .
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%至次编译器设置完成%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在matlab的Command window中输入:
>> deploytool
Matlab产生deployment tool配置窗口



单击新建按钮,新建工程------>选择MATLAB Builder NE 选项卡----->选择.NET Component并添加工程名eaqual(测试用名,其实工程名称就是你导入C#后的命名空间名称,Matlab会在当前工作目录中新建文件夹文件夹名既为equal)---->点击ADD File按钮将你需要编译的MATLAB函数添加进当前工程,我这里导入的是 D:\Program Files\MATLAB\R2008b\toolbox\aero\aero\angle2quat.m文件---->点击build.
deployment tool output 窗口输出以下信息:
Build output( 2009-03-28 15:32:55).

[url=matlab:mcc%20-F%20%27E:%5CMATLAB%5Ceaqual.prj%27]mcc -F 'E:\MATLAB\eaqual.prj'[/url]
等待...................................有点久
当输出以下信息时编译成功了

Compiler version: 4.9 (R2008b) Warning: Duplicate directory name: E:\MATLAB. mcc -W 'dotnet:eaqual,Eaqual,0.0,private' -d 'E:\MATLAB\eaqual\src' -T 'link:lib' -v 'class{Eaqual:\Program Files\MATLAB\R2008b\toolbox\aero\aero\angle2quat.m}' Warning: Name is nonexistent or not a directory: D:\Program Files\MATLAB\R2008b\toolbox\compiler\patch. Warning: Name is nonexistent or not a directory: D:\Program Files\MATLAB\R2008b\toolbox\compiler\patch. Processing D:\Program Files\MATLAB\R2008b\toolbox\aero\mcc.enc Processing D:\Program Files\MATLAB\R2008b\toolbox\matlab\mcc.enc Processing include files... 2 item(s) added. Processing directories installed with MCR... The file E:\MATLAB\eaqual\src\mccExcludedFiles.log contains a list of functions excluded from the CTF archive. 2 item(s) added. Generating MATLAB path for the compiled application... Created 40 path items. Begin validation of MEX files: Sat Mar 28 15:35:11 2009 End validation of MEX files: Sat Mar 28 15:35:11 2009 Warning: Name is nonexistent or not a directory: D:\Program Files\MATLAB\R2008b\toolbox\compiler\patch. Deleting 0 temporary MEX authorization files. Parsing file "D:\Program Files\MATLAB\R2008b\toolbox\aero\aero\angle2quat.m" (Referenced from: "Compiler Command Line"). Parsing file "D:\Program Files\MATLAB\R2008b\toolbox\compiler\deploy\deployprint.m" (Referenced from: "Compiler Command Line"). Parsing file "D:\Program Files\MATLAB\R2008b\toolbox\compiler\deploy\printdlg.m" (Referenced from: "Compiler Command Line"). Generating file "E:\MATLAB\eaqual\src\Eaqual.cs". Generating file "E:\MATLAB\eaqual\src\EaqualNative.cs". Generating file "E:\MATLAB\eaqual\src\readme.txt". Generating file "E:\MATLAB\eaqual\src\dotnet_mcc_component_data.cs". Executing command: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe /nologo /optimize /doc:"E:\MATLAB\eaqual\src\eaqual.xml" /t:library /r:"D:\Program Files\MATLAB\R2008b\toolbox\dotnetbuilder\bin\win32\v2.0\MWArray.dll" /resource:"E:\MATLAB\eaqual\src\eaqual.ctf" /out:"E:\MATLAB\eaqual\src\eaqual.dll" "E:\MATLAB\eaqual\src\Eaqual.cs" "E:\MATLAB\eaqual\src\dotnet_mcc_component_data.cs" Executing command: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe /nologo /optimize /doc:"E:\MATLAB\eaqual\src\eaqualNative.xml" /t:library /r:"D:\Program Files\MATLAB\R2008b\toolbox\dotnetbuilder\bin\win32\v2.0\MWArray.dll" /resource:"E:\MATLAB\eaqual\src\eaqual.ctf" /out:"E:\MATLAB\eaqual\src\eaqualNative.dll" "E:\MATLAB\eaqual\src\EaqualNative.cs" "E:\MATLAB\eaqual\src\dotnet_mcc_component_data.cs"   
Copying: E:\MATLAB\eaqual\src\eaqual.dll -> E:\MATLAB\eaqual\distrib
Copying: E:\MATLAB\eaqual\src\eaqualNative.dll -> E:\MATLAB\eaqual\distrib
Copying: E:\MATLAB\eaqual\src\readme.txt -> E:\MATLAB\eaqual\distrib
Compilation completed succesfully. The output is located in E:\MATLAB\eaqual\distrib.
You can package the component by clicking on the "ackage" icon in the Deployment Tool toolbar, or by clicking the Tools->ackage menu when the Deployment Tool panel is selected. To include additional files in the package, click Project->Settings).


生成的文件在工程文件夹里面
我的是  E:\MATLAB\eaqual\distrib\angle2quat.dll
至此MATLAB的操作全部完成

打开VISUAL Studio 2008新建C#工程我这里用的是控制台名为TestOfmatlab_consolt
我的是  E:\Visual Studio 2008\Projects\TEST\TestOfmatlab_consolt
添加引用E:\MATLAB\eaqual\distrib\angle2quat.dll
和D:\Program Files\MATLAB\R2008b\toolbox\dotnetbuilder\bin\win32\v2.0\MWArray.dll
(这里我没有用MATLAB画图,所以只引用MWArray.dll)
加入命名空间:
using MathWorks.MATLAB.NET.Arrays;
将下面代码加入Main函数
            eaqual.Eaqual eq=new eaqual.Eaqual();
            MathWorks.MATLAB.NET.Arrays.MWArray m=10,n=4,j=7,k;

           
             MWArray S = "XYZ";

            k = eq.angle2quat((MWNumericArray)m, (MWNumericArray)n, (MWNumericArray)j,

                               (MWCharArray)S);
            MWNumericArray temp = (MWNumericArray)k;
            double[,] location = (double[,])temp.ToArray(MWArrayComponent.Real);
            Console.WriteLine(location[0,0].ToString());
            Console.WriteLine(location[0,1].ToString());
            Console.WriteLine(k[2].ToString());
            Console.WriteLine(k[3].ToString());
            Console.WriteLine(k[4].ToString());
            Console.ReadLine();


编译运行即可看到输出,此函数是姿态角转四元数函数,具体功能就不做说明了。这个例子输入输出参数转换关系都有,大家自己看看就明白了


文件源代码:C#工程源码
由于工程文件过大就只把主函数源码传上来了!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388690.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于容器制作镜像

一。镜像基础 一。基于容器制作镜像 1. 查看并关联运行的容器 [ghlocalhost ~]$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4da438fc9a8e busybox …

认识数据分析_认识您的最佳探索数据分析新朋友

认识数据分析Visualization often plays a minimal role in the data science and model-building process, yet Tukey, the creator of Exploratory Data Analysis, specifically advocated for the heavy use of visualization to address the limitations of numerical indi…

架构探险笔记10-框架优化之文件上传

确定文件上传使用场景 通常情况下,我们可以通过一个form(表单)来上传文件,就以下面的“创建客户”为例来说明(对应的文件名是customer_create.jsp),需要提供一个form,并将其enctype属…

Windows Server 2003 DNS服务安装篇

导读-- DNS(Domain Name System,域名系统)是一种组织成层次结构的分布式数据库,里面包含有从DNS域名到各种数据类型(如IP地址)的映射“贵有恒,何必三更起五更勤;最无益,只怕一日曝十日寒。”前一段时间巴哥因为一些生活琐事而中止…

arima模型怎么拟合_7个统计测试,用于验证和帮助拟合ARIMA模型

arima模型怎么拟合什么是ARIMA? (What is ARIMA?) ARIMA models are one of the most classic and most widely used statistical forecasting techniques when dealing with univariate time series. It basically uses the lag values and lagged forecast error…

[WPF]ListView点击列头排序功能实现

[WPF]ListView点击列头排序功能实现 这是一个非常常见的功能,要求也很简单,在Column Header上显示一个小三角表示表示现在是在哪个Header上的正序还是倒序就可以了。微软的MSDN也已经提供了实现方式。微软的方法中,是通过ColumnHeader Templ…

天池幸福感的数据处理_了解幸福感与数据(第1部分)

天池幸福感的数据处理In these exceptional times, the lockdown left many of us with a lot of time to think. Think about the past and the future. Think about our way of life and our achievements. But most importantly, think about what has been and would be ou…

红草绿叶

从小到大喜欢阴天,喜欢下雨,喜欢那种潮湿的感觉。却又丝毫容不得脚上有一丝的水汽,也极其讨厌穿凉鞋。小时候特别喜欢去山上玩,偷桃子柿子,一切一切都成了美好的回忆,长大了,那些事情就都不复存…

詹森不等式_注意詹森差距

詹森不等式背景 (Background) In Kaggle’s M5 Forecasting — Accuracy competition, the square root transformation ruined many of my team’s forecasts and led to a selective patching effort in the eleventh hour. Although it turned out well, we were reminded t…

数据分析师 需求分析师_是什么让分析师出色?

数据分析师 需求分析师重点 (Top highlight)Before we dissect the nature of analytical excellence, let’s start with a quick summary of three common misconceptions about analytics from Part 1:在剖析卓越分析的本质之前,让我们从第1部分中对分析的三种常…

JQuery发起ajax请求,并在页面动态的添加元素

页面html代码&#xff1a; <li><div class"coll-tit"><span class"coll-icon"><iclass"sysfont coll-default"></i>全域旅游目的地</span></div><div class"coll-panel"><div c…

MAYA插件入门

我们知道&#xff0c; MAYA 是一个基于结点的插件式软件架构&#xff0c;这种开放式的软件架构是非常优秀的&#xff0c;它可以让用户非常方便地在其基础上开发一些自已想要的插件&#xff0c;从而实现一些特殊的功能或效果。 在MAYA上开发自已的插件&#xff0c;你有3种选择&a…

(原創) 如何使用C++/CLI读/写jpg檔? (.NET) (C++/CLI) (GDI+) (C/C++) (Image Processing)

Abstract因为Computer Vision的作业&#xff0c;之前都是用C# GDI写&#xff0c;但这次的作业要做Grayscale Dilation&#xff0c;想用STL的Generic Algorithm写&#xff0c;但C Standard Library并无法读取jpg档&#xff0c;用其它Library又比较麻烦&#xff0c;所以又回头想…

猫眼电影评论_电影的人群意见和评论家的意见一样好吗?

猫眼电影评论Ryan Bellgardt’s 2018 movie, The Jurassic Games, tells the story of ten death row inmates who must compete for survival in a virtual reality game where they not only fight each other but must also fight dinosaurs which can kill them both in th…

c#对文件的读写

最近需要对一个文件进行数量的分割&#xff0c;因为数据量庞大&#xff0c;所以就想到了通过写程序来处理。将代码贴出来以备以后使用。 //读取文件的内容 放置于StringBuilder 中 StreamReader sr new StreamReader(path, Encoding.Default); String line; StringBuilder sb …

ai前沿公司_美术是AI的下一个前沿吗?

ai前沿公司In 1950, Alan Turing developed the Turing Test as a test of a machine’s ability to display human-like intelligent behavior. In his prolific paper, he posed the following questions:1950年&#xff0c;阿兰图灵开发的图灵测试作为一台机器的显示类似人类…

关于WKWebView高度的问题的解决

关于WKWebView高度的问题的解决 IOS端嵌入网页的方式有两种UIWebView和WKWebView。其中WKWebView的性能要高些;WKWebView的使用也相对简单 WKWebView在加载完成后&#xff0c;在相应的代理里面获取其内容高度&#xff0c;大多数网上的方法在获取高度是会出现一定的问题&#xf…

测试nignx php请求并发数,nginx 优化(突破十万并发)

一般来说nginx 配置文件中对优化比较有作用的为以下几项&#xff1a;worker_processes 8;nginx 进程数&#xff0c;建议按照cpu 数目来指定&#xff0c;一般为它的倍数。worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;为每个进…

mardown 标题带数字_标题中带有数字的故事更成功吗?

mardown 标题带数字统计 (Statistics) I have read a few stories on Medium about writing advice, and there were some of them which, along with other tips, suggested that putting numbers in your story’s title will increase the number of views, as people tend …

使用Pandas 1.1.0进行稳健的2个DataFrames验证

Pandas is one of the most used Python library for both data scientist and data engineers. Today, I want to share some Python tips to help us do qualification checks between 2 Dataframes.Pandas是数据科学家和数据工程师最常用的Python库之一。 今天&#xff0c;我…