File Exchange

image thumbnail


version 1.2.22 (53.3 KB) by Henry Giddens
A Matlab to CST Interface


Updated 03 Nov 2020

From GitHub

View Version History

View license on GitHub

Use to programmatically control the commercial EM solver, CST Microwave Studio, through MATLAB.
- Build and run complex simulation problems in CST Microwave Studio programatically from MATLAB
- Build complex geometries in the CST from MATLAB scripts
- Directly import results from CST into MATLAB for analysis and plotting
- Visualize CST Simulation setup in MATLAB figures.
See Examples for different ways software can be used. Created and tested in MATLAB R2018a but should work with recent versions (at least from R2017a). Will only work on Windows Platform as uses actxserver as a COM server to CST. Should work with all latest versions of CST (tested with 2017-2019).

Cite As

Henry Giddens (2021). hgiddenss/CST_App (, GitHub. Retrieved .

Comments and Ratings (30)

Letian e

Excellent work!
Please add a 'getting post-processing' function.Thanks!

Elijah Uche

Alright Dr. Henry,
Thank you for your support.
I have emailed you with more details.
Many thanks

Henry Giddens

Hi Elija, Please feel free to email me with more details of your problem (

Elijah Uche

Hi Dr Henry,
Please, I am trying to convert my 1D and 2D rough surface models developed in MATLAB to CST,
I have tried to develop these models in CST, but to no avail, therefore I would like you to assist me with the conversion of these MATLAB models to CST

bahman mohammadi

Marcello Gostl

Hi Dr. Henry,
I sent you a mail describing my problem, can you please look into it please.

Mahesh Babu Dhanekula

Hi Dr. Henry,
I sent you a mail describing my problem, can you please look into it

Rahul Yadav

I have to assign an inhomogeneous permittivity profile for a rectangular object.
In MATLAB, I can create an inhomogeneous profile through a parametric model and assign it to each central grid point. And can save the grid location and value in ".txt file".
Now, Is it possible to assign this permittivity map or profile in CST by using your function?


Nicole Mera

Hi Henry,
Thanks a lot for your answer, It was really helpful. I've sent you an email with some questions. I'll really appreciate your assitance

Henry Giddens

Hi Nicole,
I don't know if you are aware, but you can do this in CST manually - once you have run your simulation and calculated the far-field pattern, under the far-field tab there is a button called "Array Factor" in the top left of the window. This allows you to calculate the array pattern based on element spacing and phase shift. If you set this up before you run your simulation, it should always show the calculated array pattern. You could also do this yourself in matlab by reading the far-field pattern for a single element and then calculating the array factor for your array - you can see the equations required for this (for regular, rectangular arrays) by clicking on the help button in the Array Factor box.
If you are wondering whether it is possible to control the CST array factor calculation from Matlab, then yes it is, you just need to work out the correct VBA commands and execute them in CST. However, as I prefer to work in Matlab I haven't implemented this in the code. If I wanted to know the array pattern then I would read in the pattern for the single element and calculate the overall array pattern from the theory. If you need any further assistance then please feel free to email me


Nicole Mera

Hi, thank you it was really useful.
I am currently working on the design of antenna arrays, is there any way to control the postprocessing options to combine the farfield radiation diagrams of the individual elements to get the array pattern?

jalil ur rehman kazim

I have sent you an email with some description of the problem.

Henry Giddens

Hi Jalil, I can give you some help with your problem if you send me an email:

Thanks, henry for the reply. I was actually making a reflectarray design. Which at the end I got successful. A reflectarray has typically some fixed interelement distance and different geometric size based on a phased gradient. With the help of the code, I could generate square patches with a certain inter-element distance among them. With each loop the required geometric size based on calculated phases is also generated at the same time.
What I actually meant earlier was the code generates square patch geometry. If I want to generate e.g. a Hexagonal patch or semi circle geometry with some stubs coming out of the patch. How do you think should I approach the problem.

Frauke Gellersen

Hi Henry,
thank you very much for the quick answer! I have used; CST.quit; without CST.closeProject;. I think that was my problem. (I am using CST 2019 as well and I also found no option to turn off that dialogue.)
Thank you very much again!!

Henry Giddens

Hi Frauke,
I dont seem to get this problem when I am working (Using the latest version of this code and CST 2019), as long as I have saved the project file, and in that case the prompt only asks that I want to save the file. It could be a setting in CST, but I couldnt find anything when i looked through the preferences. Have you tried the following sequence?; CST.closeProject; CST.quit; If not, you can try asking CST support whether there is a way to turn off that dialogue

Frauke Gellersen

thank you very much this has helped to speed up my work a lot!
I have one question though. Is there a way to automatically close the "Do you really want to quit the application?" dialogue from CST? This comes up sometimes after quitting CST from Matlab and it stops the script until I press yes manually. The dialogue also appears, if I saved the cst file before quitting.
Thank you again!!

Henry Giddens

Hi jalil

I don't think it will be too difficult to add different dimension patch objects into the CST file, however it is difficult for me to help without being able to see your code. Feel free to send me a PM with more information

Dear Giddens

I found the interface quite useful. I was able to export some metasurface based geometry to CST using this interface. I was designing a reflectarray which requires arbitary patch dimensions and different spacing as well. It was very hard for me to play with geometry in the matlab code. As the inter-patch distance in the code is fixed. I couldnt figure out a way to put my own calculated patch dimensions in the code.

Jesus Sanchez

Yes, I just found it. Thanks and sorry for the confusion!

Henry Giddens

If you type "methods CST_MicrowaveStudio" the "addWaveguidePort" method should be in the list? Note that to call it then you have to have an instance of of the CST_MicrowaveStudio class saved in the workspace. e.g: CST = CST_MicrowaveStudio; CST.addWaveguidePort('zmax',(0 5),(0 10), 5);
Yes, that was the intended behavior. Every time you create a new project CST adds a load of new files in a temporary directory and I wanted to avoid clogging up my hard drive unless the project is manually saved. In this way the software at least behavior mirrors the way in which you would use the GUI.

Jesus Sanchez

Hello Henry! Thanks again for this amazing job. While looking for the addWaveguidePort method, my matlab says "The class CST_MicrowaveStudio has no Constant property or Static method named 'addWaveguidePort'.". However that is not a problem, with your other functions as a reference I will try to create it myself :).

On the other hand, I have been playing around a little bit with the examples. If I understood them right, when creating a new non-existent CST project, the file is saved in the current working directory. However, this does not happen for me (CST 2019). The file is not saved, but rather it stays as "untitled" until I save it manually. Is that the intended behavior?

Henry Giddens

Hi Jesus, Yes you can create waveguide ports using the addWaveguidePort method (type help CST_MicrowaveStudio.addWaveguidePort for help guidelines), and you can open existing cst files without affecting the history list, then add new entries and it wont be overwritten. To open an existing file just run CST= CST_MicrowaveStudio(folder,[filename,'.cst']), and the existing file should open.

Jesus Sanchez

Amazing stuff! Thank you for uploading this. I have two questions about it.
- Is it possible to create waveguide ports? I have been looking for the function for it, but did not see it.
- Does with work with already created CST files. Meaning, if there is already a history list it will add new entries, instead of overwriting them.

Again, amazing job and thank you very much!


Wenzel Lasinger

Yihan Ma

dace zha

MATLAB Release Compatibility
Created with R2019a
Compatible with R2017a to R2019a
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!