23rd Annual Review of Progress in Applied Computational Electromagnetics March 19-23, 2007 - Verona, Italy ©2007 ACES Interfacing FEKO and MATLAB for Microstrip Antenna Design Randy L. Haupt The Pennsylvania State University Applied Research Laboratory P. O. Box 30 State College, PA 16804-0030 haupt@ieee.org Abstract: This paper provides details on how to use MATLAB as an effective interface to FEKO. Code to implement this interface and an example are presented. Keywords: MATLAB, FEKO, optimization, microstrip antenna 1. Introduction Combining FEKO's [1] electromagnetic modeling power with MATLAB's [2] signal processing and graphics capability, results in a powerful computational electromagnetics tool. These software tools can be run using command line files. Some situations that are advantageous to combine MATLAB and FEKO include antenna design optimization, adaptive antennas, antenna placement on a vehicle, and radar cross section modification. The next section describes how to combine MATLAB and FEKO and some specific commands that make it all happen. These commands are used in a demonstration example to design a microstrip patch antenna. 2. Calling FEKO from MATLAB MATLAB and FEKO make use of the ASCII files shown in Table 1. All the files have the same name, so they are easy to associate with the same project. The extensions differentiate their use. The MATLAB commands are in mpatch.m. Data written from MATLAB to be used by FEKO is stored in the mpatch.txt file. FEKO commands are in the mpatch.pre file. Data written by FEKO for use by MATLAB is written in the mpatch.ffe and mpatch.out files. Figure 1 displays a flowchart of the MATLAB-FEKO software performance. The flowchart boxes contain the operation to be performed, while the software package that performs the operation is listed to the right of the box. Table 1. Relevant computer files. File name contents mpatch.m MATLAB m file mpatch.txt ASCII file with variable values mpatch.pre PREFEKO file mpatch.out FEKO output file mpatch.ffe FEKO file with angles, electric field, gain 332 23rd Annual Review of Progress in Applied Computational Electromagnetics March 19-23, 2007 - Verona, Italy ©2007 ACES Figure 1. MATLAB-FEKO flowchart. Assume that MATLAB has created an antenna design in a way that all the (x,y,z) coordinates of the design are known. These coordinates are written to the text file, mpatch.txt using fid=fopen('mpatch.txt','w'); N=length(xa); fprintf(fid,'%6.2f\n',N); for iq=1:N fprintf(fid,'3%6.2f\n',xa(iq),ya(iq),za(iq)); end fclose(fid); The file, mpatch.txt, has N+1 lines. The first line contains the number of points. The following N lines contain the coordinates of the points. Next, MATLAB draws a picture of the antenna design and labels the points. In this example, the antenna is a microstrip antenna (Figure 2). figure(1);plot(xa,ya,'-o');axis equal for ii=1:length(xa) text(xa(ii),ya(ii)+za(ii),num2str(ii)) end This part of the code is not necessary, but is quite helpful in getting the geometry correct in FEKO. The following commands run PREFEKO and FEKO from MATLAB: !prefeko mpatch > output.txt !runfeko mpatch > output.txt The "> output.txt" part of the commands places output generated in the running of PREFEKO and FEKO into a file rather than displaying them on the computer screen. 333 23rd Annual Review of Progress in Applied Computational Electromagnetics March 19-23, 2007 - Verona, Italy ©2007 ACES The lines in PREFEKO that read from the text file and create the points defining the outline of the antenna are given by #N= fileread("mpatch.txt",1,1) !!for #i = 1 to #N #ax[#i]= fileread("mpatch.txt",1+#i,1) #ay[#i]= fileread("mpatch.txt",1+#i,2) #az[#i]= fileread("mpatch.txt",1+#i,3) DP p#i #ax[#i] !!next #ay[#i] #az[#i] The defining points on the antenna are labeled p1 to pN. After these points are formed in FEKO, then the structure is built out of triangles, polygons, wires, etc. FEKO performs the calculations and writes the output to mpatch.out and possibly to other files, such as mpatch.ffe. MATLAB can easily read the ASCII file where the far field information is written using the textread command [t,p,rEt,iEt,rEp,iEp,gt,gp,g] =textread('mpatch.ffe','2%f (%f,%f) (%f,%f) 3%f'); Reading from mpatch.ffe is more difficult but possible using m-files downloaded from the MATLAB website [2]. 3. Microstrip Antenna Design Example As an example, a rectangular microstrip patch antenna is designed using FEKO-MATLAB interface. The goal is to minimize s11 by varying Lx Patch length in x-direction Ly Patch width in y-direction w g Microstrip feed line width Length of inset gap in x-direction The first run minimized s11 at 2 GHz. The resulting patch had the dimensions (in mm): [Lx Ly cp gp]= 51.1612 34.2412 1.4555 18.5485 The second run minimized s11 from 1.99 to 2.01 GHz. The resulting patch had the dimensions: [Lx Ly cp gp]= 51.5962 36.8475 1.6520 17.2615 A plot of s11 over a 1% bandwidth is shown in Figure 3. A genetic algorithm combined with FMINSEARCH in MATLAB performed the optimization. As expected, attempting to get 1% bandwidth from this structure is very difficult. The steps used to perform this simple optimization apply to much more complex antenna designs. 334 23rd Annual Review of Progress in Applied Computational Electromagnetics March 19-23, 2007 - Verona, Italy ©2007 ACES Figure 2. Figure drawn by MATLAB before passing point to FEKO. Figure 3. s11 when patch optimize at 2 GHz (dashed line) and from 1.99 to 2.0 GHz (solid line). 4. Conclusions Combining FEKO and MATLAB has many advantages. MATLAB has signal processing and graphics capabilities that are useful while FEKO has the electromagnetic computational engine needed for antenna design. This paper showed a simple example of using MATLAB-FEKO to design a rectangular microstrip patch antenna. References [1] FEKO Suite 5.1, EM Software and Systems (www.feko.info), 2005. [2] MATLAB Version 7.3.0.267, The (www.mathworks.com), Aug 3, 2006. 335