CST DS用VBA定義隔離器
來源:
更新時間:2024-07-31
閱讀:
最近看一篇論文,在DS工作室用VB控件模塊代替理想隔離器。
具體做法是將Miscellaneous中的VB模塊放入視圖桌面(一定要在naviation tree先右擊VBA1,在properties對話框將其設為2 ports,并且勾選 show parameters table inside drawing,否則就顯示不了)。
然后可以對該模塊進行edit,根據其源代碼編輯其S參數。對于理想隔離器,其S矩陣
{S11 S12; S21 S22 } 應為{0 0;1 0}
但我不大懂VB,不知道怎樣改寫該程序代碼得到我想的S參數矩陣
煩請高手幫忙指點指點,謝謝!
經過這幾天不斷試驗,問題解決了!代碼共享!
Function OnS(f As Double, i As Integer, j As Integer) As Variant
'Insert code here
'First parameter is current frequency in Hz
'i and j are 1-based indices
Dim Sij(2) As Double
If i=j Then
Sij(1)=0
Sij(2)=0
ElseIf i>j Then
Sij(1)=-1
Sij(2)=0
Else
Sij(1)=0
Sij(2)=0
End If
OnS = Sij
End Function