各位大侠们,我用matlab生成的一个dll文件用来出图的,可是运行的时候是弹出的matlab的那种生成图,我想直接在我的image控件里显示出来,不知道怎么写,哪位高手指教一下,
我下面把后台程序给大家看一下
using MathWorks.MATLAB.NET.Arrays;
using testdraw;//dll文件
protected void Button1_Click(object sender, EventArgs e)
{ testdraw.testclass x1 = new testclass();
// draw.draw11 x1 = new draw11();
double[,] dd = new double[2, 3];
dd[0, 0] = 1;
dd[0, 1] = 2;
dd[0, 2] = 3;
dd[1, 0] = 2;
dd[1, 1] = 4;
dd[1, 2] = 6;
MathWorks.MATLAB.NET.Arrays.MWNumericArray d = (MathWorks.MATLAB.NET.Arrays.MWNumericArray)dd;
x1.drawgraph(d); }
顺便把testdraw的M文件也写过来
%最小二乘法直线拟合
%Created by Safirst C. Ke 2007.8.29 Wed 14:51function drawgraph(coords)
%传入的参数为两行向量,第一行为x坐标,第二行为坐标。%axis ([0 100 0 100]);
grid on;
hold on;%显示欲拟合的点的位置
plot(coords(1,:), coords(2,:), '*');%分解x,y坐标
x = coords(1,:);
y = coords(2,:)';b = size(coords);
c = ones(1, b(2));
MT = [c; x];
M = MT';
%f为直线函数,f = mx + b;
f = inv(MT * M) * MT * y;
['y = ', num2str(f(2)), 'x + ', num2str(f(1))];
%显示最终拟合的直线
x = -max(x):max(x);
y = f(1) + f(2) * x;
plot(x, y);
xlabel('X轴');
ylabel('Y轴');
title('最小二乘法直线拟合 by Safirst C. Ke');
legend(['y = ', num2str(f(2)), 'x + ', num2str(f(1))]);
我下面把后台程序给大家看一下
using MathWorks.MATLAB.NET.Arrays;
using testdraw;//dll文件
protected void Button1_Click(object sender, EventArgs e)
{ testdraw.testclass x1 = new testclass();
// draw.draw11 x1 = new draw11();
double[,] dd = new double[2, 3];
dd[0, 0] = 1;
dd[0, 1] = 2;
dd[0, 2] = 3;
dd[1, 0] = 2;
dd[1, 1] = 4;
dd[1, 2] = 6;
MathWorks.MATLAB.NET.Arrays.MWNumericArray d = (MathWorks.MATLAB.NET.Arrays.MWNumericArray)dd;
x1.drawgraph(d); }
顺便把testdraw的M文件也写过来
%最小二乘法直线拟合
%Created by Safirst C. Ke 2007.8.29 Wed 14:51function drawgraph(coords)
%传入的参数为两行向量,第一行为x坐标,第二行为坐标。%axis ([0 100 0 100]);
grid on;
hold on;%显示欲拟合的点的位置
plot(coords(1,:), coords(2,:), '*');%分解x,y坐标
x = coords(1,:);
y = coords(2,:)';b = size(coords);
c = ones(1, b(2));
MT = [c; x];
M = MT';
%f为直线函数,f = mx + b;
f = inv(MT * M) * MT * y;
['y = ', num2str(f(2)), 'x + ', num2str(f(1))];
%显示最终拟合的直线
x = -max(x):max(x);
y = f(1) + f(2) * x;
plot(x, y);
xlabel('X轴');
ylabel('Y轴');
title('最小二乘法直线拟合 by Safirst C. Ke');
legend(['y = ', num2str(f(2)), 'x + ', num2str(f(1))]);
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货