日期:2014-05-17  浏览次数:21222 次

4. Matlab函数产生的Figure图形框如何嵌入C# Winform中的一个Panel中?
 求解答啊,困扰好久了~来高手~~~~
winform matlab 图形 c#

------解决方案--------------------
Matlab  调用 .net  ,很简单, 比如, 在matllab 中 调用.Net 的 WinForms
NET.addAssembly('System.Windows.Forms')
ff = System.Windows.Forms.Form() ; 
...


Matlab,和其它语言,互操,已经很方便了


.Net 调用Matlab ,有很多途径
比如,你的要求, 可以用 Matlab Builder NE
而 plot 绘图, 直接有 
matlabroot\toolbox\dotnetbuilder\Examples\VS8\NET\PlotExample
文件夹内, example:
PlotApp.cs
PlotCSApp.csproj
AssemblyInfo.cs
上面是C#, 还有Cpp,VB等版本
------解决方案--------------------
C# 调用 matlab的范例


using System;

using MathWorks.MATLAB.NET.Utility;
using MathWorks.MATLAB.NET.Arrays;

using PlotComp;

....

            {
              const int numPoints= 10;  // Number of points to plot

              // Allocate native array for plot values
              double [,] plotValues= new double[2, numPoints];

              // Plot 5x vs x^2
              for (int x= 1; x <= numPoints; x++)
                {
                  plotValues[0, x-1]= x*5;
                  plotValues[1, x-1]= x*x;
                }

              // Create a new plotter object
              Plotter plotter= new Plotter();

              // Plot the two sets of values - Note the ability to cast&nbs