资源简介
C#引用COM组件调用Matlab,可以实现图像嵌入C#,能操作Matlab实现大多数功能,本例子实现了显示正弦图,显示三维螺旋线图等5种操作。
本人习惯vb.net编程,从vb.net转过来,vb.net不需要引用即可
引用COM组件Matlab Application(Version 8.3) Type Library//根据自己安装的版本引用

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//用来记录命令串
string str1=““;
MLApp.MLApp matlab=new MLApp.MLApp();
public Form1()
{
InitializeComponent();
}
private void ShowPic()//显示图片
{
PictureBox1.Image = Image.FromFile(“d:\\Test1.jpg“);
}
//延时程序
public void delay(long t)//延时程序
{
long temp = Environment.TickCount;
while (Environment.TickCount - temp < t)
{
Application.DoEvents();
}
}
private void Form1_Load(object sender EventArgs e)
{
matlab.Visible = 0;
}
private void Form1_FormClosing(object sender System.Windows.Forms.FormClosingEventArgs e)
{
matlab.Quit();
//退出
matlab = null;
//释放资源
}
private void Button1_Click(object sender EventArgs e)
{
PictureBox1.Image = null;
delay(100) ;//这里必不可少
str1 = “t=1:0.1:2*pi;y=sin(t);plot(ty)“;
matlab.Execute(str1);
matlab.Execute(“print( gcf ‘-djpeg‘ ‘d:\\Test1‘)“) ;//把图像保存到指定位置
matlab.Execute(“close all“);//关闭所有窗口
ShowPic(); //显示图片
}
private void Button2_Click(object sender EventArgs e)
{
PictureBox1.Image = null;
delay(100);//这里必不可少
str1 = “sale=[100 150 400 250];pie3(sale[0 0 1 0]{‘春季‘‘夏季‘‘秋季‘‘冬季‘})“;
matlab.Execute(str1);
matlab.Execute(“print( gcf ‘-djpeg‘ ‘d:\\Test1‘)“);//把图像保存到指定位置
matlab.Execute(“close all“);//关闭所有窗口
ShowPic(); //显示图片
}
private void Button3_Click(object sender EventArgs e)
{
PictureBox1.Image = null;
delay(100);//这里必不可少
str1 = “t=0:0.1:8*pi;plot3(sin(t)cos(t)t)“;
matlab.Execute(str1);
matlab.Execute(“print( gcf ‘-djpeg‘ ‘d:\\Test1‘)“);//把图像保存到指定位置
matlab.Execute(“close all“);//关闭所有窗口
ShowPic(); //显示图片
}
private void Button4_Click(object sender EventArgs e)
{
PictureBox1.Image = null;
delay(100);//这里必不可少
str1 = “k = 5;n = 2^k-1;[xyz] = sphere(n);c = hadamard(2^k);surf(xyzc);“;
str1 = str1 + “colormap ([1 1 0; 0 1 1]);axis equal“;
matlab.Execute(str1);
matlab.Execute(“print( gcf ‘-djpeg‘ ‘d:\\Test1‘)“);//把图像保存到指定位置
matlab.Execute(“close all“);//关闭所有窗口
ShowPic(); //显示图片
}
private void Button5_Click(object sender EventArgs e)
{
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11264 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\bin\Debug\Csharp_matlab.exe
文件 26112 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\bin\Debug\Csharp_matlab.pdb
文件 14328 2015-08-12 10:57 Csharp_matlab\Csharp_matlab\bin\Debug\Csharp_matlab.vshost.exe
文件 490 2015-03-27 14:34 Csharp_matlab\Csharp_matlab\bin\Debug\Csharp_matlab.vshost.exe.manifest
文件 8704 2015-08-12 10:33 Csharp_matlab\Csharp_matlab\bin\Debug\Interop.MLApp.dll
文件 9728 2015-08-12 10:32 Csharp_matlab\Csharp_matlab\bin\Debug\WindowsFormsApplication1.exe
文件 26112 2015-08-12 10:32 Csharp_matlab\Csharp_matlab\bin\Debug\WindowsFormsApplication1.pdb
文件 14328 2015-08-12 10:33 Csharp_matlab\Csharp_matlab\bin\Debug\WindowsFormsApplication1.vshost.exe
文件 490 2015-03-27 14:34 Csharp_matlab\Csharp_matlab\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest
文件 11264 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\bin\Release\Csharp_matlab.exe
文件 22016 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\bin\Release\Csharp_matlab.pdb
文件 8704 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\bin\Release\Interop.MLApp.dll
文件 3689 2015-08-12 10:33 Csharp_matlab\Csharp_matlab\Csharp_matlab.csproj
文件 74 2015-08-12 10:33 Csharp_matlab\Csharp_matlab\Csharp_matlab.csproj.user
文件 3715 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\Form1.cs
文件 5817 2015-08-12 10:40 Csharp_matlab\Csharp_matlab\Form1.Designer.cs
文件 5814 2015-08-12 10:40 Csharp_matlab\Csharp_matlab\Form1.resx
文件 1196 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\obj\Debug\Csharp_matlab.csproj.FileListAbsolute.txt
文件 847 2015-08-12 10:40 Csharp_matlab\Csharp_matlab\obj\Debug\Csharp_matlab.csproj.GenerateResource.Cache
文件 520 2015-08-12 10:33 Csharp_matlab\Csharp_matlab\obj\Debug\Csharp_matlab.csproj.ResolveComReference.cache
文件 11264 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\obj\Debug\Csharp_matlab.exe
文件 26112 2015-08-12 10:42 Csharp_matlab\Csharp_matlab\obj\Debug\Csharp_matlab.pdb
文件 8704 2015-08-12 10:33 Csharp_matlab\Csharp_matlab\obj\Debug\Interop.MLApp.dll
文件 1328 2015-08-12 10:33 Csharp_matlab\Csharp_matlab\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt
文件 847 2015-08-12 10:32 Csharp_matlab\Csharp_matlab\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache
文件 520 2015-08-12 10:26 Csharp_matlab\Csharp_matlab\obj\Debug\WindowsFormsApplication1.csproj.ResolveComReference.cache
文件 9728 2015-08-12 10:32 Csharp_matlab\Csharp_matlab\obj\Debug\WindowsFormsApplication1.exe
文件 180 2015-08-12 10:40 Csharp_matlab\Csharp_matlab\obj\Debug\WindowsFormsApplication1.Form1.resources
文件 26112 2015-08-12 10:32 Csharp_matlab\Csharp_matlab\obj\Debug\WindowsFormsApplication1.pdb
文件 180 2015-08-12 10:36 Csharp_matlab\Csharp_matlab\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources
............此处省略30个文件信息
相关资源
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
评论
共有 条评论