Updated 21 Jul 2019
======= Introduction =======
This `TCSTInterface` class allows for communication with CST Microwave Studio (CST Studio Suite) from within MATLAB using Windows' COM technology.
The main goal of this submission is to control an **existing** CST project, get and post-process the simulation results, export geometry and get various information from the project. If there is a need to **build** the geometry programmatically, there is another good submission in Matlab File Exchange (https://se.mathworks.com/matlabcentral/fileexchange/67731-hgiddenss-cst_app) which suits better for that.
======== Features ==========
This CST-MATLAB interface features the following:
### Model control:
- Open/close CST project, connect to the active one;
- Store/change/read/enumerate parameters of the model with or without the model rebuild, getting parameters' expressions.
- Copy all model parameters and their values to MATLAB workspace.
- Enumerate/add/delete field monitors.
- Find Run ID for the given parameter combination.
- Run selected solver;
- Preparing the CST project for evaluating the cost function in MATLAB while optimizing. It can also be used for running a custom MATLAB function as the CST simulation post-processing step ("Template Based Post-Processing").
### Retrieving results:
- Enumerate tree items in the Navigation Tree.
- Read 1D results from any tree item with several available filters.
- 1D results can be queried for a specific X-coordinate (often frequency), optionally with interpolation.
- Read S- or Z-parameters in a convenient matrix form for multi-port structures.
- Get model parameters corresponding to each Run ID in the Result Navigator.
- All queries for results can have a Run ID filter.
- Read radiation field for both single-frequency and broadband field monitors.
- Reading results for parametric sweeps done in CST. As an option, each such result can be organized in a matrix, each dimension of which corresponds to one of the swept parameters.
- Export S-parameters to TOUCHSTONE file by means of CST;
- Export current model view to an image. User can rotate the model view before exporting.
- Export the model geometry to an STL file (triangulated objects) with surface approximation control.
### View control (useful for image exporting):
- Rotate 3D view to predefined position or custom view direction (like in MATLAB "view" function).
- Toggle wire-frame view.
- Toggle gradient background.
### Getting various information:
- About materials used in the project: name, color, transparency.
- About geometrical objects (solids): name, component, material, color and transparency (exactly how it looks in CST), volume, mass.
- CST license info.
- Project units for different quantities and coefficient to convert them to SI units.
In addition, a customized STL-file reader is included in order to plot geometry like they are seen in CST MWS.
One of the class methods (`ReadParametricResults`) use two custom classes (`TResultsStorage` and `TMyTable`). I apologize for not providing source code for them, but they are not yet in the state to go public :)
If other functionality is desired, please post a feature request here: https://github.com/korvin011/CSTMWS-Matlab-Interface/issues
==== DEMOS / DOCUMENTATION ====
All functionalities are well documented in the included Live Script demos. MATLAB R2018a or higher is desired in order to not loose code samples in the demos.
======== Bugs found? ==========
If you encounter any errors or notice some misfunction while using the interface, please open an issue directly in GitHub (https://github.com/korvin011/CSTMWS-Matlab-Interface/issues).
======= Acknowledgment ========
I would like to thank Jan Simon for his great function `GetFullPath` (https://se.mathworks.com/matlabcentral/fileexchange/28249-getfullpath), it is very helpful for this interface.
Oleg Iupikov (2021). TCSTInterface - CST Studio Suite to MATLAB Interface (https://github.com/korvin011/CSTMWS-Matlab-Interface), GitHub. Retrieved .
Thank you for the fantastic toolbox.
I am using this on a machine with multiple CST installations (2020 and 2021).
When using the toolbox, the model is automatically opened in CST 2021, but I would like to use CST 2020.
Is it possible to select which version the toolbox will use? Alternatively, is there a setting that I can change on my machine to accomplish this?
Highly recommend this MATLAB repo if you are trying to automate data processing with CST. I was on the wrong track working with C++ and storage files directly, and doing all the automation with the MATLAB interface is much easier.
Yeah, that is what I ended up doing. But I really needed know if I was missing something, ahah. Great tool though. Thank you!
(Thank you for the nice resource as well)
Unfortunately, it is not possible in the current implementation. Here (theta,phi)-components of the far-field are exported always. You need manually convert them to (RHC,LHC)-components, and then calculate the axial ratio. See e.g. here (https://www.kildal.se/wp-content/uploads/2017/03/Kildal-FoAE-1703-color-Cover.pdf), p.39.
How does one access, if possible, Axial Ratio values or Right Polarisation in the FarField section?
I've read the info in the Field Structure document, but I don't understand how to manipulate polarization, for example. The ExportFarField function does not allow one to specify this, or am I missing something?
Thank you for your response. The issue I have is that I am trying to generate a rough surface on CST from MATLAB. I have looked at the stlwrite function in MATLAB but it complained that the input argument must be a triangulation object. I now tried implementing the triangulation using the delaunay function like U earlier advised/suggested, but I was not getting the desired results, as a result, I am still stuck. So my question now is how do I use the delaunay function to triangulate my 2D/3D surface to enable me now create an STL file from the triangulated surface/object? Once I am able to create an STL file, I can now continue from there & import it to CST then continue my analysis from there. So that's been my challenge these past weeks nd any answers/solutions/support/assistance/help/clues/hints I can extract from this forum is appreciated. I can also send you a private email message if you can furnish me with your email address, so I can clarify my questions or doubts in more detail in the email message. Many thanks for your help &support as always
@Elijah, It is not clear what kind of issue do you have. And sorry to say, but triangulation issues are completely off-topic, since this page is devoted to the MATLAB-CST interface. I also do not look here often and can offer only very limited support regarding the interface. It is much better and faster for you to ask such questions in a proper forum like here, in Matlab Central, or external, like StackOverflow or similar, describing clearly your problem including error messages.
Please any update with regards my question below?
I have tried implementing the triangulation using the delaunay function as advised/suggested, BUT I am still stuck as I am not achieving the desired results.
How do I use the delaunay function to triangulate the surface? Kindly assist as I keep getting loads of error messages when trying to use the delaunay function.
Many thanks for your support as always..
Thank you for your kind response. I have tried to create an STL file using this command stlwrite('surf.stl', X, Y, Z) but I always get this error message
Error using stlwrite (line 25)
Input argument must be a triangulation object.
I guess I will have to use the delaunay function to triangulate the surface, but how do I go about this so I would not be getting those error messages
Thank U for your support as always.
@Elijah, I believe this can be solved easily without any interface. You can create STL file and import it to CST. See MATLAB functions 'triangulation' and 'stlwrite'. If your surface is not yet triangulated, you can do so using 'delaunay' function.
Please I would like to convert my 1D and 2D rough surface models developed in MATLAB to CST
I have tried to develop the models in CST but to no avail, therefore, I will appreciate if U could assist me with this conversion from MATLAB to CST
@Mahesh, When you create an activex object of PowerPoint application, for example, by "App = actxserver('PowerPoint.Application')", MATLAB knows about syntax of all its methods (at least that ones that are described in its interface). You can check it e.g. by executing "methodsview(App)". Same approach will work with all other objects within this App (e.g. "methodsview(App.Presentations.Item(1))" if some presentation is open). However, in CST it is not the case. MATLAB doesn't know anything about CST objects' methods, and therefore you cannot use dot-notation when calling Obj's methods, and need to use "Obj.invoke(MethodName, Param1, ...)", which you can get only from CST documentation, its history list or translate from VBA examples. I believe I mentioned this in one of the demos.
"CST has not implemented interface for their COM objects (at least in the version 2019 and below)" May I know what does this means ?
Very helpful and insightful. Thanks for your great contribution man.
Inspired by: hgiddenss/CST_App
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!