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.pswp.cn/news/388690.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388690.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388690.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

洛谷P3273 [SCOI2011] 棘手的操作 [左偏樹]

題目傳送門 棘手的操作 題目描述 有N個節點,標號從1到N,這N個節點一開始相互不連通。第i個節點的初始權值為a[i],接下來有如下一些操作: U x y: 加一條邊,連接第x個節點和第y個節點A1 x v: 將第x個節點的權值增加vA2 x…

基于容器制作鏡像

一。鏡像基礎 一。基于容器制作鏡像 1. 查看并關聯運行的容器 [ghlocalhost ~]$ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4da438fc9a8e busybox …

照顧好自己才能照顧好別人_您必須照顧的5個基本數據

照顧好自己才能照顧好別人I am pretty sure that on your data journey you came across some courses, videos, articles, maybe use cases where someone takes some data, builds a classification/regression model, shows you great results, you learn how that model wo…

matlab數字仿真實驗,DVR+備用電源自動投入的MATLAB數字仿真實驗仿真實驗

一、動態電壓恢復器(DVR)的數字仿真實驗動態電壓恢復器(Dynamic Voltage Restorer,DVR)是一種基于電力電子技術的串聯補償裝置,通常安裝在電源與敏感負荷之間,其作用在于:保證電網供電質量,補償供電電網產生的電壓跌落…

c#,xp系統,Matlab6.5

編譯環境:c#,xp系統,Matlab6.5 新建一個窗體項目,添加matlab引用。 然后試了四種方式調用matlab: 第一種 view plaincopy to clipboardprint?MLApp.MLAppClass matlab new MLApp.MLAppClass(); matlab.Visible 1;…

java script 對象

java script 對象 1.創建方式 1)通過字面量的形式創建 例;var stt{x:1,y:2,y:3}; 或;var stt{ x:1, y:2, for:3 } 注意關鍵字必須放到引號中間 2)通過new創建對象 例:var new stt(); stt.name 小魚; stt.age 20…

認識數據分析_認識您的最佳探索數據分析新朋友

認識數據分析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屬…

matlab飛行數據仿真,基于MATLAB的飛行仿真

收稿日期: 2005 - 05 - 15   第 23卷  第 06期 計  算  機  仿  真 2006年 06月    文章編號: 1006 - 9348 (2006) 06 - 0057 - 05 基于 MATLAB的飛行仿真 張鐳 ,姜洪洲 ,齊潘國 ,李洪人 (哈爾濱工業大學電液伺服仿真及試驗系統研究所 ,黑龍江 哈爾濱 150001) 摘要:該…

Windows Server 2003 DNS服務安裝篇

導讀-- DNS(Domain Name System,域名系統)是一種組織成層次結構的分布式數據庫,里面包含有從DNS域名到各種數據類型(如IP地址)的映射“貴有恒,何必三更起五更勤;最無益,只怕一日曝十日寒。”前一段時間巴哥因為一些生活瑣事而中止…

正則表達式matlab,正則表達式中一個word的匹配?@MATLAB - 優秀的Free?OS(Linux)版 - 北大未名BBS...

我目前想做的就是判斷一個str是否可以被認為是有效的MATLAB index。最好的方法是直接運行,然后看運行結果或報錯類型,但是我不打算在不知道是什么類型的東西之前運行它,所以可以預先parse一下,簡單判斷是否“長得跟有效的MATLAB i…

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…

jQuery禁止Ajax請求緩存

一 現象 get請求在有些瀏覽器中會緩存。瀏覽器不會發送請求,而是使用上次請求獲取到的結果。 post請求不會緩存。每次都會發送請求。 二 解決 jQuery提供了禁止Ajax請求緩存的方法: $.ajax({type: "get",url: "http://www.baidu.com?_&…

python 實例

參考 http://developer.51cto.com/art/201804/570408.htm 轉載于:https://www.cnblogs.com/artesian0526/p/9552510.html

[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…

標線markLine的用法

series: [{markLine: {itemStyle: {normal: { lineStyle: { type: solid, color:#000 },label: { show: true, position:left } }},data: [{name: 平均線,// 支持 average, min, maxtype: average},{name: Y 軸值為 100 的水平線,yAxis: 100},[{// 起點和終點的項會共用一個 na…

php pfm 改端口,羅馬2ESF和PFM 修改建筑 軍團 派系 兵種等等等很多東西的教程

本帖最后由 clueber 于 2013-10-5 12:30 編輯本人是個羅馬死忠加修改黨,恩,所以分享一下自己的修改心得修改工具為ESF1.0.7和PFM3.0.3首先是ESF修改。ESF可以用來改開局設定和存檔,修改開局設定是startpos.esf文件,在存檔在我這里…

紅草綠葉

從小到大喜歡陰天,喜歡下雨,喜歡那種潮濕的感覺。卻又絲毫容不得腳上有一絲的水汽,也極其討厭穿涼鞋。小時候特別喜歡去山上玩,偷桃子柿子,一切一切都成了美好的回憶,長大了,那些事情就都不復存…

wpf listview 使用

單列&#xff1a; <ListView Grid.Column"1" Height"284" HorizontalAlignment"Left" Margin"64,73,0,0" Name"listView1" VerticalAlignment"Top" Width"310" > <ListView.Items…