function SF=antenaCST(parameters, additionalParameters)
global cst mws fid;
sir=parameters(1);
vys=parameters(2);
del_zar=parameters(3);
tl_zar=parameters(4);
% add paths to the required m-files.
addpath('../component/');
addpath('../global/');
addpath('../check3d/');
addpath('../Import_Export/');
addpath('../material/');
addpath('../monitors/');
addpath('../operation on solids/');
addpath('../ports/');
addpath('../results/');
addpath('../solids/');
addpath('../solver/');
 
% Vytvoreni souboru temp
tmpScriptFile = 'c:/tmp_moravec/matlabea/VYSLEDKY/tmpData.m';

% Pojmenovani docasneho temp adresare pro ulozeni .mod souboru.
tmpAdrSoub = 'c:/tmp_moravec/matlabea/VYSLEDKY/test/test.mod';

% Vytvoreni docasneho souboru, ve kterem buou zapisovany/cteny vysledky
CFileName = 'c:/tmp_moravec/matlabea/VYSLEDKY/ExportCst_S11.txt'; 


% Create a new temporary CST script file.
fid = fopen(tmpScriptFile, 'wt');

%definovani pormennych
% del_zar=9;
% sir=34.776826205;%37.7;
tl_sub=1.6;
% tl_zar=0.2;
% vys=30.158941744;%28.4;
x_port=6;
y_port=7.1;

%Vytvoreni modelu pomoci funkci 
CstNewProject(fid);
CstUnits(fid,'easy','mm','gHz','ns','','','','','','','');
CstMaterialExist('Copper');
CstNewComponent(fid,'P_ant');
CstBrick(fid,'Antena','P_ant','Copper',-sir/2,sir/2,-vys/2,vys/2,tl_sub,tl_sub+0.035);
CstBrick(fid,'zarez1','P_ant','Vacuum',-sir/2,-(sir/2)+del_zar,-tl_zar/2,tl_zar/2,tl_sub,tl_sub+0.035);
CstSolid(fid,'Subtract','P_ant','Antena','zarez1');
CstBrick(fid,'zarez2','P_ant','Vacuum',(sir/2)-del_zar,sir/2,-tl_zar/2,tl_zar/2,tl_sub,tl_sub+0.035);
CstSolid(fid,'Subtract','P_ant','Antena','zarez2');
CstBrick(fid,'zarez3','P_ant','Vacuum',-tl_zar/2,tl_zar/2,-(vys/2),-(vys/2)+del_zar,tl_sub,tl_sub+0.035);
CstSolid(fid,'Subtract','P_ant','Antena','zarez3');
CstBrick(fid,'zarez4','P_ant','Vacuum',-tl_zar/2,tl_zar/2,(vys/2)-del_zar,vys/2,tl_sub,tl_sub+0.035);
CstSolid(fid,'Subtract','P_ant','Antena','zarez4');
CstNewComponent(fid,'G_ant');
CstBrick(fid,'Ground','G_ant','Copper',-(sir/2)-7.3,(sir/2)+12.25,-(vys/2)-13.05,((vys/2)+8),-0.035,0);
CstMaterialExist('FR4');%%%%%%%%%%
CstNewComponent(fid,'S_ant');
CstBrick(fid,'Substrat','S_ant','FR-4 (lossy)',-(sir/2)-7.3,(sir/2)+12.25,-(vys/2)-13.05,(vys/2)+8,0,tl_sub);
CstNewComponent(fid,'P_port');
CstBrick(fid,'Port1','G_ant','Copper',-(12.7/2)+x_port,(12.7/2)+x_port,-(12.7/2)+y_port,(12.7/2)+y_port,-1.635,-0.035);
CstCylinder(fid,'Konektor','G_ant','Copper','Z',5.3/2,0,x_port,y_port,-9.635,-1.635,0);
CstCylinder(fid,'Dira','S_ant','Vacuum','Z',1.5/2,0,x_port,y_port,0,tl_sub,0);
CstSolid(fid,'Subtract','S_ant','Substrat','Dira');
CstCylinder(fid,'Dira1','G_ant','Vacuum','Z',2/2,0,x_port,y_port,-0.035,0,0);
CstSolid(fid,'Subtract','G_ant','Ground','Dira1');
CstCylinder(fid,'Dira2','G_ant','Vacuum','Z',4.3/2,0,x_port,y_port,-1.635,-0.035,0);
CstSolid(fid,'Subtract','G_ant','Port1','Dira2');
CstCylinder(fid,'Dira2','G_ant','Vacuum','Z',4.3/2,0,x_port,y_port,-9.635,-1.635,0);
CstSolid(fid,'Subtract','G_ant','Konektor','Dira2');
CstCylinder(fid,'Coax','P_ant','Copper','Z',1.2/2,0,x_port,y_port,-9.635,tl_sub,0);
CstDeleteComponent(fid,'P_port');
CstBackground(fid,'Normal',1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,'Normal',0.0,'True');
CstSetFrekvencyRange(fid,1,3);
CstWaveguidePort(fid,1,1,'False',0.0,0,45,'Free','zmin','True','False',...
    -(5.3/2)+x_port,(5.3/2)+x_port,-(5.3/2)+y_port,(5.3/2)+y_port,-9.635,-9.635,...
    0.0,0.0,0.0,0.0,0.0,0.0);
CstBoundary(fid,'expanded open','expanded open','expanded open','expanded open','open','expanded open','none',...
    'none','none','isothermal','isothermal','isothermal','isothermal','isothermal','isothermal',...
    'False','','','','','','',...
    'None','None','None','None','None','None');
CstMonitor(fid,'farfield (f=2)','Frequency','Farfield',2);
CstMonitor(fid,'farfield (f=1.6433)','Frequency','Farfield',1.6433);
CstTimeDomainSolverEasy(fid,'TD-S','All','All',-30,'False','False',50,'False','False','False','False','False');
CstStartSolver(fid);
% VectorFaS = GetFrequencyFromDiagram(0.5)
% VectorFaS = CstGetFrequencyResults;
VectorFaS=CstGetfrequencyFromSavedFile(CFileName,0.5,'S',[1 1])
SF = VectorFaS(1,1);
CstSaveAsProject(tmpAdrSoub);
CstCloseProject;
%run (tmpScriptFile);
