Application Note Matlab Calls CST
Application Note Matlab Calls CST
Abstract ...................................................................................................................................... 1
1. Launch CST from Matlab command line ............................................................................... 2
1.1. Example 1: launch CST, open an existing model, solve, save ........................................ 2
2. Launch and control CST from a Matlab .m file ................................................................... 2
2.1. Starting CST DESIGN ENVIRONMENT and opening an MWS window .................... 3
2.2. Translating CST-specific VBA commands into Matlab ................................................. 3
2.3. Useful commands some examples ............................................................................... 4
2.4. Example 1 again: launch CST, open an existing model, solve, save .............................. 5
2.5. Example 2: Open an MWS file, perform a parameter study, store a result in a Matlab
vector ...................................................................................................................................... 5
Abstract
This application note gives background information on linking CST Studio to Matlab, by
calling CST directly from Matlab.
For information on how to call Matlab from within CST Studio, please see the separate
Application Note CST_USER_NOTE__MATLAB_COM_DDE.pdf .
Methods
There are two main ways to call CST Studio from within Matlab:
1) launch CST from Matlab command line and use a separate VBA file to instruct CST
what operations to do
2) run a Matlab .m file containing CST Studio commands
2006\CST
DESIGN
The user has access to all CST-specific VBA commands, by means of the Matlab command
invoke.
To open a new MWS window in CST DS, the following syntax is used:
mws = invoke(cst, 'NewMWS')
To open an existing MWS model, you can (just as if you were working interactively within
CST DS):
- open the model directly into CST DS:
mws = invoke(cst, 'OpenFile', filename.cst');
- or, first open an empty MWS window, then open the model in this window:
mws = invoke(cst, 'NewMWS')
invoke(mws, 'OpenFile', filename.cst');
Note: if several bricks need to be created, the pair of commands brick = invoke(mws,
'Brick') and release(brick) only need to be issued once.
% Set the
% Example for
% S11 linear
numOfValue = invoke(result, 'GetN'); % Might be used to
% initialize variables
invoke(result, 'Save', 'C:\tmp\filename');
A = importdata('C:\tmp\filename', ' ', 4)
x = A.data(:, 1);
% x-data column
y = A.data(:, 2);
% y-data column