├── README.md ├── fullstructure1.m └── matlabcstapi ├── LumpedSetm.m ├── addm.m ├── drawbrick.m ├── drawcylinder.m ├── intializing.m ├── materialdef.m ├── modcfg.m ├── name.m └── subtractm.m /README.md: -------------------------------------------------------------------------------- 1 | # matlab-cst api 2 | matlab-cst api 使用history list写入 3 | 添加函数代码到matlab路径 4 | 样例为30*30 时空二维编码超表面 5 | 6 | %mws = invoke(cst,'OpenFile',cstproject);%为打开工程语句,样例为新建 7 | -------------------------------------------------------------------------------- /fullstructure1.m: -------------------------------------------------------------------------------- 1 | clc; 2 | clear; 3 | close all; 4 | %初始化设置 5 | cst = actxserver('CSTStudio.application');%首先载入CST应用控件 6 | mws = invoke(cst, 'NewMWS');%新建一个MWS项目 7 | app = invoke(mws, 'GetApplicationName');%获取当前应用名称 8 | ver = invoke(mws, 'GetApplicationVersion');%获取当前应用版本号 9 | %命名 10 | %-------------------------------------------------------------------------- 11 | Name2='test'; 12 | name(mws,Name2); 13 | %-------------------------------------------------------------------------- 14 | 15 | %-------------------------------------------------------------------------- 16 | intializing(mws); 17 | %%CST文件初始化结束 18 | %参数编辑区,利用invoke函数添加参数 19 | %例: 20 | %a=38.6; 21 | %invoke(mws, 'StoreParameter','a',a); 22 | %-------------------------------------------------------------------------- 23 | l=5.6; 24 | a=6.5; 25 | t=0.018; 26 | h=2.0; 27 | m=0.525; 28 | d=0.3; 29 | %-------------------------------------------------------------------------- 30 | %定义材质 31 | Name='material1'; 32 | Epsilon=2.65; 33 | TanD=0.015; 34 | materialdef(mws, Name,Epsilon,TanD); 35 | %-------------------------------------------------------------------------- 36 | Name = 'bot'; 37 | component = 'component1'; 38 | material = 'PEC'; 39 | Xrange = [-a*30/2 a*30/2]; 40 | Yrange = [-a*30/2 a*30/2]; 41 | Zrange = [0 t]; 42 | drawbrick(mws, Name, component, material, Xrange, Yrange, Zrange); 43 | NameBot=Name; 44 | for i=1:30 45 | Name=''; 46 | Name='bot'; 47 | add=int2str(i); 48 | Name=[Name add]; 49 | cy=-(i-1)*a+14.5*a; 50 | Xrange=[-a*30/2 a*30/2]; 51 | Yrange=[cy-0.1 cy+0.1]; 52 | Zrange=[0 t]; 53 | drawbrick(mws, Name,component,material,Xrange,Yrange,Zrange); 54 | subtractm(mws,NameBot,component,Name,component); 55 | end 56 | 57 | Name = 'sub'; 58 | component = 'component1'; 59 | material = 'material1'; 60 | Xrange = [-a*30/2 a*30/2]; 61 | Yrange = [-a*30/2 a*30/2]; 62 | Zrange = [t t+h]; 63 | drawbrick(mws, Name, component, material, Xrange, Yrange, Zrange); 64 | NameSub='sub'; 65 | 66 | 67 | for i=1:30 68 | for j=1:30 69 | ti=i; 70 | tj=j; 71 | cx=(ti-1)*a-14.5*a; 72 | cy=-(tj-1)*a+14.5*a; 73 | 74 | add= ''; 75 | add = [add 'left',int2str(i),'_',int2str(j)]; 76 | %draw top left 77 | Name1='top'; 78 | Name1=[Name1 add]; 79 | component = 'component1'; 80 | material = 'PEC'; 81 | Xrange = [cx-l/2 cx-0.6]; 82 | Yrange = [cy-l/2 cy+l/2]; 83 | Zrange = [t+h t*2+h]; 84 | drawbrick(mws, Name1, component, material, Xrange, Yrange, Zrange); 85 | %draw hole left 86 | Name11='hole'; 87 | Name11=[Name11 add]; 88 | material = 'material1'; 89 | Xcenter=cx-0.8; 90 | Ycenter=cy+l/2-0.2; 91 | OutR=0.15; 92 | InnerR=0; 93 | Zrange2=[t t+h]; 94 | drawcylinder(mws,Name11,component,material,OutR,InnerR,Xcenter,Ycenter,Zrange2); 95 | subtractm(mws,NameSub,component,Name11,component); 96 | %draw bias left 97 | Name12='bias'; 98 | Name12=[Name12 add]; 99 | material = 'PEC'; 100 | Xcenter=cx-0.8; 101 | Ycenter=cy+l/2-0.2; 102 | OutR=0.15; 103 | InnerR=0; 104 | Zrange2=[t t+h]; 105 | drawcylinder(mws,Name12,component,material,OutR,InnerR,Xcenter,Ycenter,Zrange2); 106 | addm(mws,NameBot,component,Name12,component); 107 | %perfect top left 108 | material='PEC'; 109 | Name13='top13'; 110 | Name14='top14'; 111 | Name15='top15'; 112 | Name16='top16'; 113 | Name17='top17'; 114 | Name13=[Name13 add]; 115 | Name14=[Name14 add]; 116 | Name15=[Name15 add]; 117 | Name16=[Name16 add]; 118 | Name17=[Name17 add]; 119 | Xrange=[cx-l/2+m-d cx-l/2+m]; 120 | Yrange=[cy-l/2+0.2 cy+l/2-0.2]; 121 | drawbrick(mws,Name13,component,material,Xrange,Yrange,Zrange); 122 | Xrange=[cx-l/2+2*m-d cx-l/2+2*m]; 123 | drawbrick(mws,Name14,component,material,Xrange,Yrange,Zrange); 124 | Xrange=[cx-l/2+3*m-d cx-l/2+3*m]; 125 | drawbrick(mws,Name15,component,material,Xrange,Yrange,Zrange); 126 | Xrange=[cx-l/2+4*m-d cx-l/2+4*m]; 127 | Yrange=[cy+l/2-0.7 cy+0.4]; 128 | drawbrick(mws,Name16,component,material,Xrange,Yrange,Zrange); 129 | Yrange=[cy-l/2+0.7 cy-0.4]; 130 | drawbrick(mws,Name17,component,material,Xrange,Yrange,Zrange); 131 | subtractm(mws,Name1,component,Name13,component); 132 | subtractm(mws,Name1,component,Name14,component); 133 | subtractm(mws,Name1,component,Name15,component); 134 | subtractm(mws,Name1,component,Name16,component); 135 | subtractm(mws,Name1,component,Name17,component); 136 | 137 | %--------------------------------------------------------------------------------------------------------- 138 | add= ''; 139 | add = [add 'right',int2str(i),'_',int2str(j)]; 140 | %draw top right 141 | Name2='top'; 142 | Name2=[Name2 add]; 143 | component = 'component1'; 144 | material = 'PEC'; 145 | Xrange = [cx+0.6 cx+l/2]; 146 | Yrange = [cy-l/2 cy+l/2]; 147 | Zrange = [t+h t*2+h]; 148 | drawbrick(mws, Name2, component, material, Xrange, Yrange, Zrange); 149 | %draw hole right 150 | Name21='hole'; 151 | Name21=[Name21 add]; 152 | material = 'material1'; 153 | Xcenter=cx+0.8; 154 | Ycenter=cy-l/2+0.2; 155 | OutR=0.15; 156 | InnerR=0; 157 | Zrange2=[t t+h]; 158 | drawcylinder(mws,Name21,component,material,OutR,InnerR,Xcenter,Ycenter,Zrange2); 159 | subtractm(mws,NameSub,component,Name21,component); 160 | %draw bias right 161 | Name22='bias'; 162 | Name22=[Name22 add]; 163 | material = 'PEC'; 164 | Xcenter=cx+0.8; 165 | Ycenter=cy-l/2+0.2; 166 | OutR=0.15; 167 | InnerR=0; 168 | Zrange2=[t t+h]; 169 | drawcylinder(mws,Name22,component,material,OutR,InnerR,Xcenter,Ycenter,Zrange2); 170 | addm(mws,NameBot,component,Name22,component); 171 | %perfect top left 172 | material='PEC'; 173 | Name23='top23'; 174 | Name24='top24'; 175 | Name25='top25'; 176 | Name26='top26'; 177 | Name27='top27'; 178 | Name23=[Name23 add]; 179 | Name24=[Name24 add]; 180 | Name25=[Name25 add]; 181 | Name26=[Name26 add]; 182 | Name27=[Name27 add]; 183 | Xrange=[cx+l/2-m cx+l/2-m+d]; 184 | Yrange=[cy-l/2+0.2 cy+l/2-0.2]; 185 | drawbrick(mws,Name23,component,material,Xrange,Yrange,Zrange); 186 | Xrange=[cx+l/2-2*m cx+l/2-2*m+d]; 187 | drawbrick(mws,Name24,component,material,Xrange,Yrange,Zrange); 188 | Xrange=[cx+l/2-3*m cx+l/2-3*m+d]; 189 | drawbrick(mws,Name25,component,material,Xrange,Yrange,Zrange); 190 | Xrange=[cx+l/2-4*m cx+l/2-4*m+d]; 191 | Yrange=[cy+l/2-0.7 cy+0.4]; 192 | drawbrick(mws,Name26,component,material,Xrange,Yrange,Zrange); 193 | Yrange=[cy-l/2+0.7 cy-0.4]; 194 | drawbrick(mws,Name27,component,material,Xrange,Yrange,Zrange); 195 | subtractm(mws,Name2,component,Name23,component); 196 | subtractm(mws,Name2,component,Name24,component); 197 | subtractm(mws,Name2,component,Name25,component); 198 | subtractm(mws,Name2,component,Name26,component); 199 | subtractm(mws,Name2,component,Name27,component); 200 | end 201 | end 202 | %180deg=1 203 | R14V=2.857; 204 | L14V=0.7; 205 | C14V=0.3061; 206 | %0deg=0 207 | R0V=4.514; 208 | L0V=0.7; 209 | C0V=2.3; 210 | %matr 211 | matr=3; 212 | K=zeros(matr); 213 | 214 | 215 | for i=1:30 216 | for j=1:30 217 | ti=i; 218 | tj=j; 219 | cx=(ti-1)*a-14.5*a; 220 | cy=-(tj-1)*a+14.5*a; 221 | NameP='Port'; 222 | addp=''; 223 | addp=[addp int2str(i),'_',int2str(j)]; 224 | NameP=[add addp]; 225 | RangeP1=[cx-0.6 cy t*2+h]; 226 | RangeP2=[cx+0.6 cy t*2+h]; 227 | if (K(i,j)==0) 228 | LumpedSetm(mws,NameP,R0V,L0V,C0V,RangeP1,RangeP2); 229 | else 230 | LumpedSetm(mws,NameP,R14V,L14V,C14V,RangeP1,RangeP2); 231 | end 232 | end 233 | end 234 | -------------------------------------------------------------------------------- /matlabcstapi/LumpedSetm.m: -------------------------------------------------------------------------------- 1 | function LumpedSetm(mws,Name,R,L,C,RangeP1,RangeP2) 2 | Str_Name=Name; 3 | sCommand=''; 4 | sCommand=[sCommand 'With LumpedElement']; 5 | sCommand=[sCommand 10 '.Reset']; 6 | sCommand=[sCommand 10 '.SetName "',Str_Name,'"']; 7 | sCommand=[sCommand 10 '.Folder "Folder1"']; 8 | sCommand=[sCommand 10 '.SetType "RLCSerial"']; 9 | sCommand=[sCommand 10 '.SetR "',num2str(R),'"']; 10 | sCommand=[sCommand 10 '.SetL "',num2str(L),'e-9"']; 11 | sCommand=[sCommand 10 '.SetC "',num2str(C),'e-12"']; 12 | sCommand=[sCommand 10 '.SetGs "0"']; 13 | sCommand=[sCommand 10 '.SetI0 "1e-14"']; 14 | sCommand=[sCommand 10 '.SetT "300"']; 15 | sCommand=[sCommand 10 '.SetP1 "False", "',num2str(RangeP1(1),'%.5f'),'", "',num2str(RangeP1(2),'%.5f'),'", "',num2str(RangeP1(3),'%.5f'),'"']; 16 | sCommand=[sCommand 10 '.SetP2 "False", "',num2str(RangeP2(1),'%.5f'),'", "',num2str(RangeP2(2),'%.5f'),'", "',num2str(RangeP2(3),'%.5f'),'"']; 17 | sCommand=[sCommand 10 '.SetInvert "False"']; 18 | sCommand=[sCommand 10 '.SetMonitor "True"']; 19 | sCommand=[sCommand 10 '.SetRadius "0.0"']; 20 | sCommand=[sCommand 10 '.Wire ""']; 21 | sCommand=[sCommand 10 '.Position "end1"']; 22 | sCommand=[sCommand 10 '.CircuitFileName ""']; 23 | sCommand=[sCommand 10 '.CircuitId "1"']; 24 | sCommand=[sCommand 10 '.UseCopyOnly "True"']; 25 | sCommand=[sCommand 10 '.UseRelativePath "False"']; 26 | sCommand=[sCommand 10 '.Create']; 27 | sCommand=[sCommand 10 'End With']; 28 | invoke(mws, 'AddToHistory',['define lumped element:Folder1:',Name], sCommand); 29 | end 30 | 31 | %{ 32 | With LumpedElement 33 | .Reset 34 | .SetName "element1" 35 | .Folder "Folder1" 36 | .SetType "RLCSerial" 37 | .SetR "80" 38 | .SetL "1.114e-9" 39 | .SetC "1.111e-12" 40 | .SetGs "0" 41 | .SetI0 "1e-14" 42 | .SetT "300" 43 | .SetP1 "False", "1", "2", "3" 44 | .SetP2 "False", "4", "5", "6" 45 | .SetInvert "False" 46 | .SetMonitor "True" 47 | .SetRadius "0.0" 48 | .Wire "" 49 | .Position "end1" 50 | .CircuitFileName "" 51 | .CircuitId "1" 52 | .UseCopyOnly "True" 53 | .UseRelativePath "False" 54 | .Create 55 | End With 56 | %} -------------------------------------------------------------------------------- /matlabcstapi/addm.m: -------------------------------------------------------------------------------- 1 | function addm(mws,Name1,Com1,Name2,Com2) 2 | sCommand=''; 3 | sCommand=[sCommand 'Solid.Add "',Com1,':',Name1,'", "',Com2,':',Name2,'"'] 4 | %boolean add shapes:component1:solid,component1:solid2 5 | %Solid.Add "component1:solid1", "component1:solid2" 6 | invoke(mws, 'AddToHistory',['boolean add shapes:',Com1,':',Name1,',',Com2,':',Name2], sCommand); 7 | end -------------------------------------------------------------------------------- /matlabcstapi/drawbrick.m: -------------------------------------------------------------------------------- 1 | function drawbrick(mws, Name, component, material, Xrange, Yrange, Zrange) 2 | % Create a brick 3 | %cst = actxserver('CSTStudio.application');%首先载入CST应用控件 4 | %mws = invoke(cst, 'NewMWS');%新建一个MWS项目 5 | %app = invoke(mws, 'GetApplicationName');%获取当前应用名称 6 | %ver = invoke(mws, 'GetApplicationVersion');%获取当前应用版本号 7 | %Name='test'; 8 | %component='component1'; 9 | %material='PEC'; 10 | %Xrange=[-93.6500 -91.4500]; 11 | %Yrange=[91.4500,97.0500]; 12 | %Zrange=[2.0180 2.0360]; 13 | 14 | Str_Name=Name; 15 | Str_Component=component; 16 | Str_Material=material; 17 | sCommand = ''; 18 | sCommand = [sCommand 'With Brick']; 19 | sCommand = [sCommand 10 '.Reset']; 20 | sCommand = [sCommand 10 '.Name "',Str_Name, '"']; 21 | sCommand = [sCommand 10 '.Component "', Str_Component, '"']; 22 | sCommand = [sCommand 10 '.Material "', Str_Material, '"']; 23 | sCommand = [sCommand 10 '.Xrange ', '"',num2str(Xrange(1),'%.5f'),'","',num2str(Xrange(2),'%.5f'),'"']; 24 | sCommand = [sCommand 10 '.Yrange ', '"',num2str(Yrange(1),'%.5f'),'","',num2str(Yrange(2),'%.5f'),'"']; 25 | sCommand = [sCommand 10 '.Zrange ', '"',num2str(Zrange(1),'%.5f'),'","',num2str(Zrange(2),'%.5f'),'"']; 26 | sCommand = [sCommand 10 '.Create']; 27 | sCommand = [sCommand 10 'End With'] ; 28 | invoke(mws, 'AddToHistory',['define brick:',Str_Component,':',Str_Name], sCommand); 29 | end 30 | -------------------------------------------------------------------------------- /matlabcstapi/drawcylinder.m: -------------------------------------------------------------------------------- 1 | function drawcylinder(mws, Name, component, material, OutR, InnerR, XCenter, YCenter, Zrange) 2 | 3 | %cst = actxserver('CSTStudio.application');%首先载入CST应用控件 4 | %mws = invoke(cst, 'NewMWS');%新建一个MWS项目 5 | %app = invoke(mws, 'GetApplicationName');%获取当前应用名称 6 | %ver = invoke(mws, 'GetApplicationVersion');%获取当前应用版本号 7 | %Name='test'; 8 | %component='component1'; 9 | %material='PEC'; 10 | %Xcenter=1.2; 11 | %Ycenter=1.2; 12 | %Zrange=[2.0180 2.0360]; 13 | %OutR=1.2; 14 | %InnerR=0; 15 | 16 | Str_Name=Name; 17 | Str_Component=component; 18 | Str_Material=material; 19 | sCommand = ''; 20 | sCommand = [sCommand 'With Cylinder']; 21 | sCommand = [sCommand 10 '.Reset']; 22 | sCommand = [sCommand 10 '.Name "',Str_Name, '"']; 23 | sCommand = [sCommand 10 '.Component "', Str_Component, '"']; 24 | sCommand = [sCommand 10 '.Material "', Str_Material, '"']; 25 | sCommand = [sCommand 10 '.OuterRadius "',num2str(OutR,'%.5f'), '"']; 26 | sCommand = [sCommand 10 '.InnerRadius "',num2str(InnerR,'%.5f'), '"']; 27 | sCommand = [sCommand 10 '.Axis "z"']; 28 | sCommand = [sCommand 10 '.Zrange ', '"',num2str(Zrange(1),'%.5f'),'","',num2str(Zrange(2),'%.5f'),'"']; 29 | sCommand = [sCommand 10 '.Xcenter "',num2str(XCenter,'%.5f'), '"']; 30 | sCommand = [sCommand 10 '.Ycenter "',num2str(YCenter,'%.5f'), '"']; 31 | sCommand = [sCommand 10 '.Segments "0"']; 32 | sCommand = [sCommand 10 '.Create']; 33 | sCommand = [sCommand 10 'End With'] ; 34 | invoke(mws, 'AddToHistory',['define cylinder:',Str_Component,':',Str_Name], sCommand); 35 | 36 | end -------------------------------------------------------------------------------- /matlabcstapi/intializing.m: -------------------------------------------------------------------------------- 1 | function intializing(mws) 2 | %%全局单位初始化 3 | sCommand = ''; 4 | sCommand = [sCommand 'With Units' ]; 5 | sCommand = [sCommand 10 '.Geometry "mm"']; 6 | sCommand = [sCommand 10 '.Frequency "ghz"' ]; 7 | sCommand = [sCommand 10 '.Voltage "V"' ]; 8 | sCommand = [sCommand 10 '.Resistance "Ohm"' ]; 9 | sCommand = [sCommand 10 '.Inductance "nH"' ]; 10 | sCommand = [sCommand 10 '.Time "ns"']; 11 | sCommand = [sCommand 10 '.Current "A"']; 12 | sCommand = [sCommand 10 '.Conductance "Siemens"']; 13 | sCommand = [sCommand 10 '.Capacitance "pF"']; 14 | sCommand = [sCommand 10 'End With'] ; 15 | invoke(mws, 'AddToHistory','define units', sCommand); 16 | %%全局单位初始化结束 17 | 18 | %%工作频率设置 19 | Frq=[7 14]; 20 | sCommand = ''; 21 | sCommand = [sCommand 'Solver.FrequencyRange ' num2str(Frq(1)) ',' num2str(Frq(2)) ]; 22 | invoke(mws, 'AddToHistory','define frequency range', sCommand); 23 | %%工作频率设置结束 24 | 25 | %%背景材料设置 26 | sCommand = ''; 27 | sCommand = [sCommand 'With Background' ]; 28 | sCommand = [sCommand 10 '.ResetBackground']; 29 | sCommand = [sCommand 10 '.Type "Normal"' ]; 30 | sCommand = [sCommand 10 'End With'] ; 31 | invoke(mws, 'AddToHistory','define background', sCommand); 32 | %%背景材料设置结束 33 | 34 | %%使Bounding Box显示,这段代码不用保存进历史树 35 | plot = invoke(mws, 'Plot'); 36 | invoke(plot, 'DrawBox', 'True'); 37 | %%使Bounding Box显示结束 38 | 39 | %%floquet端口设置 40 | sCommand = ''; 41 | sCommand = [sCommand 'With FloquetPort']; 42 | sCommand = [sCommand 10 '.Reset']; 43 | sCommand = [sCommand 10 '.SetDialogTheta "0"']; 44 | sCommand = [sCommand 10 '.SetDialogPhi "0"']; 45 | sCommand = [sCommand 10 '.SetSortCode "+beta/pw"']; 46 | sCommand = [sCommand 10 '.SetCustomizedListFlag "False"']; 47 | sCommand = [sCommand 10 '.Port "Zmin"']; 48 | sCommand = [sCommand 10 '.SetNumberOfModesConsidered "2"']; 49 | sCommand = [sCommand 10 '.Port "Zmax"']; 50 | sCommand = [sCommand 10 '.SetNumberOfModesConsidered "2"']; 51 | sCommand = [sCommand 10 'End With']; 52 | sCommand = [sCommand 10]; 53 | sCommand = [sCommand 10 'MakeSureParameterExists "theta", "0"']; 54 | sCommand = [sCommand 10 'SetParameterDescription "theta", "spherical angle of incident plane wave"']; 55 | sCommand = [sCommand 10 'MakeSureParameterExists "phi", "0"']; 56 | sCommand = [sCommand 10 'SetParameterDescription "phi", "spherical angle of incident plane wave"']; 57 | invoke(mws, 'AddToHistory','define ports', sCommand); 58 | %%floquet端口设置结束 59 | 60 | 61 | end -------------------------------------------------------------------------------- /matlabcstapi/materialdef.m: -------------------------------------------------------------------------------- 1 | function materialdef(mws, Name, Epsilon, TanD) 2 | %define a new material 3 | %cst = actxserver('CSTStudio.application');%首先载入CST应用控件 4 | %mws = invoke(cst, 'NewMWS');%新建一个MWS项目 5 | %app = invoke(mws, 'GetApplicationName');%获取当前应用名称 6 | %ver = invoke(mws, 'GetApplicationVersion');%获取当前应用版本号 7 | %Epsilon=2.65; 8 | %TanD=0.0015; 9 | %Name='material1'; 10 | Str_Name=Name; 11 | sCommand = ''; 12 | sCommand = [sCommand 'With Material']; 13 | sCommand = [sCommand 10 '.Reset']; 14 | sCommand = [sCommand 10 '.Name "',Str_Name, '"']; 15 | sCommand = [sCommand 10 '.Folder ""' 10 '.Rho "0.0"' 10 '.ThermalType "Normal"' 10 '.ThermalConductivity "0"']; 16 | sCommand = [sCommand 10 '.SpecificHeat "0", "J/K/kg"' 10 '.DynamicViscosity "0"' 10 '.Emissivity "0"']; 17 | sCommand = [sCommand 10 '.MetabolicRate "0.0"' 10 '.VoxelConvection "0.0"' 10 '.BloodFlow "0"']; 18 | sCommand = [sCommand 10 '.MechanicsType "Unused"' 10 '.FrqType "all"' 10 '.Type "Normal"']; 19 | sCommand = [sCommand 10 '.MaterialUnit "Frequency", "GHz"' 10 '.MaterialUnit "Geometry", "mm"']; 20 | sCommand = [sCommand 10 '.MaterialUnit "Time", "ns"' 10 '.MaterialUnit "Temperature", "Kelvin"']; 21 | sCommand = [sCommand 10 '.Epsilon "',num2str(Epsilon,'%.3f'),'"']; 22 | sCommand = [sCommand 10 '.Mu "1"' 10 '.Sigma "0"' 10 '.TanD "',num2str(TanD,'%.5f'),'"']; 23 | sCommand = [sCommand 10 '.TanDFreq "0.0"' 10 '.TanDGiven "True"' 10 '.TanDModel "ConstTanD"']; 24 | sCommand = [sCommand 10 '.EnableUserConstTanDModelOrderEps "False"' 10 '.ConstTanDModelOrderEps "1"']; 25 | sCommand = [sCommand 10 '.SetElParametricConductivity "False"' 10 '.ReferenceCoordSystem "Global"']; 26 | sCommand = [sCommand 10 '.CoordSystemType "Cartesian"' 10 '.SigmaM "0"' 10 '.TanDM "0.0"' 10 '.TanDMFreq "0.0"']; 27 | sCommand = [sCommand 10 '.TanDMGiven "False"' 10 '.TanDMModel "ConstTanD"']; 28 | sCommand = [sCommand 10 '.EnableUserConstTanDModelOrderMu "False"' 10 '.ConstTanDModelOrderMu "1"']; 29 | sCommand = [sCommand 10 '.SetMagParametricConductivity "False"' 10 '.DispModelEps "None"']; 30 | sCommand = [sCommand 10 '.DispModelMu "None"' 10 '.DispersiveFittingSchemeEps "Nth Order"']; 31 | sCommand = [sCommand 10 '.MaximalOrderNthModelFitEps "10"' 10 '.ErrorLimitNthModelFitEps "0.1"']; 32 | sCommand = [sCommand 10 '.UseOnlyDataInSimFreqRangeNthModelEps "False"' 10 '.DispersiveFittingSchemeMu "Nth Order"']; 33 | sCommand = [sCommand 10 '.MaximalOrderNthModelFitMu "10"' 10 '.ErrorLimitNthModelFitMu "0.1"']; 34 | sCommand = [sCommand 10 '.UseOnlyDataInSimFreqRangeNthModelMu "False"' 10 '.UseGeneralDispersionEps "False"']; 35 | sCommand = [sCommand 10 '.UseGeneralDispersionMu "False"' 10 '.NLAnisotropy "False"']; 36 | sCommand = [sCommand 10 '.NLAStackingFactor "1"']; 37 | sCommand = [sCommand 10 '.NLADirectionX "1"']; 38 | sCommand = [sCommand 10 '.NLADirectionY "0"']; 39 | sCommand = [sCommand 10 '.NLADirectionZ "0"']; 40 | sCommand = [sCommand 10 '.Colour "0", "1", "1" ']; 41 | sCommand = [sCommand 10 '.Wireframe "False" ']; 42 | sCommand = [sCommand 10 '.Reflection "False"']; 43 | sCommand = [sCommand 10 '.Allowoutline "True" ']; 44 | sCommand = [sCommand 10 '.Transparentoutline "False"']; 45 | sCommand = [sCommand 10 '.Transparency "0"']; 46 | sCommand = [sCommand 10 '.Create']; 47 | sCommand = [sCommand 10 'End With']; 48 | invoke(mws, 'AddToHistory',['define material:',Str_Name], sCommand); 49 | end -------------------------------------------------------------------------------- /matlabcstapi/modcfg.m: -------------------------------------------------------------------------------- 1 | function t=modcfg(mws,Mode) 2 | %Mode='meta_unit_cfg'; 3 | path='E:\IT_files\matlab\CST-MATLAB-API-master\CST-MATLAB-API-master\myfunc\cfg'; 4 | fullpath=[path '\',Mode,'.txt']; 5 | fid=fopen(fullpath); 6 | t=''; 7 | tline=fgetl(fid); 8 | t=[t tline]; 9 | while ischar(tline) 10 | tline=fgetl(fid); 11 | t=[t 10 tline]; 12 | end 13 | fclose(fid); 14 | end 15 | 16 | -------------------------------------------------------------------------------- /matlabcstapi/name.m: -------------------------------------------------------------------------------- 1 | function name(mws,Name) 2 | %初始化部分 3 | invoke(mws, 'FileNew'); 4 | path=pwd; 5 | filename= ''; 6 | filename=[filename '\',Name,'.cst']; 7 | fullname=[path filename]; 8 | invoke(mws, 'SaveAs', fullname, 'True'); 9 | invoke(mws, 'DeleteResults'); 10 | end -------------------------------------------------------------------------------- /matlabcstapi/subtractm.m: -------------------------------------------------------------------------------- 1 | function subtractm(mws,Name1,Com1,Name2,Com2) 2 | sCommand=''; 3 | sCommand=[sCommand 'Solid.Subtract "',Com1,':',Name1,'", "',Com2,':',Name2,'"'] 4 | %boolean subtract shapes:component1:solid,component1:solid2 5 | %Solid.Subtract "component1:solid1", "component1:solid2" 6 | invoke(mws, 'AddToHistory',['boolean subtract shapes:',Com1,':',Name1,',',Com2,':',Name2], sCommand); 7 | end --------------------------------------------------------------------------------