神秘了一场雨 发表于 2013-8-19 08:34

VB调用matlab

Private Sub Command1_Click()
Dim str1 As String
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
str1 = "a=load('" & Text1.Text & "');"
End Sub
Private Sub Command2_Click()
Dim matlab As Object
Set matlab = CreateObject("Matlab.application")
Clipboard.Clear
matlab.Execute ("n(5)=0;")
matlab.Execute ("str1")
matlab.Execute ("b=a(:,10);m=length(b);")
matlab.Execute ("for i=1:1:m")
matlab.Execute ("if abs(b(i))>100")
matlab.Execute ("n(1)=n(1)+1;")
matlab.Execute ("elseif abs(b(i))>50.8 & abs(b(i))<=100")
matlab.Execute ("n(2)=n(2)+1;")
matlab.Execute ("elseif abs(b(i))>15.8 & abs(b(i))<=50.8")
matlab.Execute ("n(3)=n(3)+1;")
matlab.Execute ("elseif abs(b(i))>10.1 & abs(b(i))<=15.8")
matlab.Execute ("n(4)=n(4)+1;")
matlab.Execute ("elseif abs(b(i))>0 & abs(b(i))<=10.1")
matlab.Execute ("n(5)=n(5)+1;")
matlab.Execute ("end")
matlab.Execute ("end")
matlab.Execute ("set(gcf,'visible','off'),pie(n);legend('100KA 以上','50.8-100KA','15.8-50.8KA','10.1-15.8KA','0-10.1KA',-1);")
matlab.Execute ("set(gcf,'color','w');print(gcf,'-dmeta')")
Picture1.Picture = Clipboard.GetData()
End Sub



求朋友们指点一下,为什么出的图是错的。。

1345389794 发表于 2015-7-23 21:25

································

1345389794 发表于 2015-7-23 21:27

好厉害!!!!!!!!!!!!
页: [1]
查看完整版本: VB调用matlab