标题:基于VB平台的simulink电力继电保护仿真
只看楼主
瓷娃娃
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-5-28
 问题点数:0 回复次数:1 
基于VB平台的simulink电力继电保护仿真
正在做一个毕设,在vb界面上显示Simulink的仿真模型且可在VB界面上修改仿真参数,下面是部分代码,求助大神帮看看,是在搞不懂


Option Explicit
Public Matlab As Object
Dim mreal(0, O) As Double
Dim minnag(0, 0) As Double
Private Sub Form_Initialize()
Set Matlab = CreateObject("matlab.application")
End Sub
'创建MATLAB的实例,初始化以及定义变量
Private Sub Commandl_Click()
'按下Command按钮后
Call Matlab.putfullmatrix("b", "base", mreal, mimag)
'将VB中数据传入Matlab的workspace中
Matlab.execute ("sim C:\Users\Administrator\Desktop\shiyan1.mdl")
'运行距离保护Simulink模型
Private Sub Form_Load()
Text3.Text = 0.2 'Text3为仿真时间
End Sub
Private Sub Image2_DblClick()
End Sub
L1参数.Show
End Sub
Private Sub Image3_DblClick()
L2参数.Show
End Sub
Private Sub Image4_DblClick()
L2参数.Show
End Sub
'三个子窗体,在线路上双击来修改三段线路参数
Private Sub Text3_Change()
mreal(0, 0) = Text3.Text
End Sub
Private Sub Command1_Click()
Call Matlab.putfullmatrix("b", "base", mreal, mimag)
'将VB中的数据传入Matlab的workspace中
Matlab.execute ("C:\Users\Administrator\Desktop\shiyan1.mdl")
'需要先仿真一遍才能修改参数
Matlab.execute ("set_param('shiyan1','stoptime','b(:,1))")
'设置仿真时间
Matlab.execute ("sim C:\Users\Administrator\Desktop\shiyan1.mdl")
If Check1.Value = 1 Then
Matlab.execute ("set_param(shiyan1/Three-Phase Fault','faultA','on)")
Else
Matlab.execute ("set_param(shiyan1/Three-Phase Fault','faultA','off)")
End If
If Check2.Value = 1 Then
Matlab.execute ("set_param(shiyan1/Three-Phase Fault','faultB','on)")
Else
Matlab.execute ("set_param(shiyan1/Three-Phase Fault','faultB','Off)")
If Check3.Value = 1 Then
Matlab.execute ("set_param(shiyan1/Three-Phase Fault','faultC','on)")
Else
Matlab.execute ("set_param(shiyan1/Three-Phase Fault','faultC','Off)")
End If
'以上代码用来设置短路类型(单相或者多相)
Matlab.execute ("sim shiyan1.mdl") '仿真
Matlab.execute ("run shiyan1") 'Maflab编程
Maflab.execute ("print-f3-dmeta")
Picture1.Picture = Clipboard.GetData
Matlab.execute ("print-f1-dmeta")
Picture2.Picture = Clipboard.GetData
Madab.execute ("print-f2一dmeta")
Picture3.Picture = Clipboard.GetData
End Sub
'以上代码为从Matlab中取出仿真结果图
搜索更多相关主题的帖子: 仿真模型 
2017-05-28 11:00
瓷娃娃
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-5-28
得分:0 
大神门能不能帮我出出主意
2017-05-28 11:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-477439-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.050117 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved