資源簡介
自己寫的一些C#調用MATLAB的例子,自己寫的一些C#調用MATLAB的例子自己寫的一些C#調用MATLAB的例子自己寫的一些C#調用MATLAB的例子

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.IO;
using?MLApp;
using?MathWorks.MATLAB.NET.Arrays;
using?MathWorks.MATLAB.NET.Utility;
using?Untitled1;
using?Untitled2;
using?ReadMat;
namespace?MATLAB
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????private?void?button1_Click(object?sender?EventArgs?e)//調用m文件
????????{
????????????int?i?=?4;
????????????int?j?=?6;
????????????//Untitled1class?c?=?new?Untitled1class();
????????????Untitled1class?c?=?new?Untitled1class();
????????????MWArray?result?=?c.test0((MWArray)i?(MWArray)j);
????????????????//test((MWArray)i?(MWArray)j);
????????????label1.Text?=?result.ToString();
????????}
????????private?void?button2_Click(object?sender?EventArgs?e)//顯示圖像
????????{
????????????Untitled2class?st?=?new?Untitled2class();
????????????int?m?=?1?n?=?2;
????????????st.test((MWArray)m?(MWArray)n);
????????}
????????private?void?button3_Click(object?sender?EventArgs?e)//存儲圖像并顯示
????????{
????????????MLApp.MLAppClass?tmatlab=new?MLApp.MLAppClass();
????????????tmatlab.Visible?=?0;
????????????string?command1?command2;
????????????command1?=?“t=0:0.01:2*pi;y=sin(t);h=figure;plot(ty);“;//matlab腳本命令行
????????????string?path=Directory.GetCurrentDirectory();//獲取當前路徑
????????????path?=?path?+?“\\Test1.jpg“;
????????????command2?=?@“print(h‘-djpeg‘‘“?+?path?+?“‘)“;
????????????tmatlab.Execute(command1);//執行matlab命令
????????????tmatlab.Execute(command2);
????????????tmatlab.Quit();
????????????tmatlab?=?null;
????????????pictureBox1.SizeMode?=?PictureBoxSizeMode.StretchImage;
????????????pictureBox1.Image?=?Image.FromFile(path);//讀取圖像
????????}
????????private?void?button4_Click(object?sender?EventArgs?e)//顯示矩陣
????????{
????????????string[]?array?=?new?string[4?2];
????????????array[0?0]?=?“001“;
????????????array[0?1]?=?“七虎在線“;
????????????array[1?0]?=?“002“;
????????????array[1?1]?=?“七虎“;
????????????array[2?0]?=?“003“;
????????????array[2?1]?=?“在線“;
????????????array[3?0]?=?“004“;
????????????array[3?1]?=?“電腦“;
????????????dataGridView1.Rows.Clear();
????????????for?(int?m?=?0;?m?4;?m++)
????????????{
????????????????dataGridView1.Rows.Add(1);
????????????????for?(int?n?=?0;?n?2;?n++)
????????????????{
????????????????????dataGridView1.Rows[m].Cells[n].Value?=?array[m?n].ToString();
????????????????}
????????????}
????????}
????????private?void?button5_Click(object?sender?EventArgs?e)//顯示mat?文件
????????{
????????????string?path?=?Directory.GetCurrentDirectory();
????????????path?+=?“\\haha.mat“;
????????????ReadMatclass?c?=?new?ReadMatclass();
????????????MWArray?r?=?c.read_mat(path);//讀取結果
????????????MWNumericArray?rn?=?(MWNumericArray)r;//強制轉成數據形式,這步不能少
?????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????179??2011-03-15?12:19??MATLAB\MATLAB\bin\Debug\haha.mat
?????文件???????8704??2011-03-14?22:45??MATLAB\MATLAB\bin\Debug\Interop.MLApp.dll
?????文件??????12800??2011-03-24?16:55??MATLAB\MATLAB\bin\Debug\MATLAB.exe
?????文件??????28160??2011-03-24?16:55??MATLAB\MATLAB\bin\Debug\MATLAB.pdb
?????文件??????14328??2011-03-24?16:59??MATLAB\MATLAB\bin\Debug\MATLAB.vshost.exe
?????文件????????490??2007-07-21?01:33??MATLAB\MATLAB\bin\Debug\MATLAB.vshost.exe.manifest
?????文件??????68782??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat.ctf
?????文件???????9216??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat.dll
?????文件????????614??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\ReadMat\read_mat.m
?????文件????????541??2011-03-15?12:25??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\ReadMat_17C22DBD94A698047AC1366220D24E1F\matlab.prf
?????文件?????????40??2011-03-12?19:31??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\ReadMat_17C22DBD94A698047AC1366220D24E1F\MLintDefaultSettings.txt
?????文件??????????0??2011-03-15?12:28??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\ReadMat_17C22DBD94A698047AC1366220D24E1F\MLintFailureFiles
?????文件???????3199??2011-03-15?12:32??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\ReadMat_17C22DBD94A698047AC1366220D24E1F\WebRenderer\pluginreg.dat
?????文件?????????53??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\Contents.m
?????文件????????824??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\ctfroot.m
?????文件???????3104??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\deployprint.m
?????文件???????7168??2008-02-10?03:14??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\deploywhich.mexw32
?????文件????????644??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\deploywhich_mexw32.auth
?????文件??????10195??2006-05-27?14:02??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\FigureMenuBar.fig
?????文件???????6944??2005-11-30?22:10??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\FigureToolBar.fig
?????文件????????749??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\fopen.m
?????文件????????869??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\input.m
?????文件????????779??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\pause.m
?????文件????????959??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\printdlg.m
?????文件????????689??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\propedit.m
?????文件???????9216??2008-02-10?03:14??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\readline.mexw32
?????文件????????644??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\compiler\deploy\readline_mexw32.auth
?????文件?????????55??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\local\Contents.m
?????文件???????1514??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\local\hgrc.m
?????文件????????929??2011-03-15?12:38??MATLAB\MATLAB\bin\Debug\ReadMat_mcr\toolbox\local\initprefs.m
............此處省略162個文件信息
評論
共有 條評論