I am trying to simulate a PCB antenna, with individual layers and via drill size/locations imported from a Gerber file/layers output. I can import this with the "pcbStack" command. However, I loose the original orientation and x-y coordinates. And I cannot create a feed point, properly, for the antenna. How do I do that?

답변 (1개)

Umar
Umar 2026년 8월 17일 21:20

0 개 추천

Hi @Scott,
Two things going on here, both expected behavior on MathWorks' side (not a bug):
Feed points: Gerber files don't carry any feed information at all — MathWorks says this outright in their Gerber-import example. So pcbStack always drops the default feed at (0,0), no matter what your actual board geometry looks like. You have to set it yourself after import:
pb = pcbStack(P1);
pb.FeedDiameter = .001;
pb.FeedLocations(1:2) = [0, 0.035]; % your real feed x,y
Coordinates/orientation: the imported polygon keeps whatever raw origin was baked into the Gerber file itself, which is often not centered or aligned the way you'd expect. Before building the pcbStack, pull the polygon and re-anchor it to something you understand:
p1 = PCBReader(StackUp=S);
s = p1.shapes;
[x,y] = centroid(s);
translate(s,[-x, -y, 0]); % or use boundingbox() for an asymmetric board
Once it's in a frame you understand, build the pcbStack from that shape and set FeedLocations relative to that same origin — that combo is likely what's been tripping you up.
One other thing worth double-checking: gerberRead only supports up to two metal layers and doesn't support cut-ins. If your board has more layers than that, that alone could explain missing geometry after import.
No automatic rotation happens on import as far as I can tell — if orientation looks off, it's most likely the same root-cause as #2: the raw Gerber coordinates don't match your mental picture of the layout, not the toolbox flipping anything. MathWorks has worked examples for all of this — search "Create Antenna Model from Gerber Files" and "Translate Center of Imported Symmetrical/Asymmetrical Polygon" in the Antenna Toolbox docs.
Hope this helps!

댓글 수: 4

Scott
Scott 2026년 8월 24일 23:10
No matter what I do, I cannot create a feedpoint in my design. I have three of the five custom antenna types, trying to just create a simple monopole shape (a long, thin rectangle shape of about a quarter wavelength), and I cannot place a feedpoint.
Maybe I am either missing some add-on functionality?
Umar
Umar 2026년 8월 25일 0:58
Hi @Scott,
Before I try to pin this down further, can you give me a bit more info? What MATLAB release are you running (just type ver and paste what comes back)? And which of the three custom antenna types is actually giving you grief — customAntenna, customAntennaMesh, or customAntennaStl?
The reason I ask is those three don't all use createFeed the same way — two of them want a location plus a number of edges, but customAntennaMesh wants two separate points instead. If you're using the same command style on all of them, that alone could be why it's failing on more than one.
It'd also help to know exactly what happens when you try — do you get an error message, or does it just quietly not create a feed? If there's an error, paste the exact text.
One thing worth trying in the meantime: instead of typing in coordinates by hand, call createFeed(c) with nothing else and it'll pop open a window where you click directly on the mesh to pick the feed edge. A lot of the "I can't get a feed point no matter what I do" issues come down to typed coordinates not lining up exactly with an edge in the mesh, and clicking it directly avoids that problem entirely.
Once I know your version and which class you're stuck on, I can give you something more exact instead of guessing.
Scott
Scott 2026년 8월 25일 15:32
Hi Umar, thank you for replying - here are answers:
1) Version: (Note: I x'ed out the license number, but it is a valid company license.)
>> ver
----------------------------------------------------------------------------
MATLAB Version: 26.1.0.3276743 (R2026a) Update 3
MATLAB License Number: xxxxxxxx
Operating System: Microsoft Windows 11 Enterprise Version 10.0 (Build 26100)
Java Version: Java is not loaded
----------------------------------------------------------------------------
MATLAB Version 26.1 (R2026a)
Simulink Version 26.1 (R2026a)
5G Toolbox Version 26.1 (R2026a)
AUTOSAR Blockset Version 26.1 (R2026a)
Aerospace Blockset Version 26.1 (R2026a)
Aerospace Toolbox Version 26.1 (R2026a)
Antenna Toolbox Version 26.1 (R2026a)
Audio Toolbox Version 26.1 (R2026a)
Automated Driving Toolbox Version 26.1 (R2026a)
Bluetooth Toolbox Version 26.1 (R2026a)
Communications Toolbox Version 26.1 (R2026a)
Control System Toolbox Version 26.1 (R2026a)
Curve Fitting Toolbox Version 26.1 (R2026a)
DDS Blockset Version 26.1 (R2026a)
DSP HDL Toolbox Version 26.1 (R2026a)
DSP System Toolbox Version 26.1 (R2026a)
Data Acquisition Toolbox Version 26.1 (R2026a)
Embedded Coder Version 26.1 (R2026a)
Fixed-Point Designer Version 26.1 (R2026a)
Global Optimization Toolbox Version 26.1 (R2026a)
HDL Coder Version 26.1 (R2026a)
HDL Verifier Version 26.1 (R2026a)
Image Acquisition Toolbox Version 26.1 (R2026a)
Image Processing Toolbox Version 26.1 (R2026a)
Instrument Control Toolbox Version 26.1 (R2026a)
LTE Toolbox Version 26.1 (R2026a)
Lidar Toolbox Version 26.1 (R2026a)
MATLAB Coder Version 26.1 (R2026a)
MATLAB Compiler Version 26.1 (R2026a)
MATLAB Compiler SDK Version 26.1 (R2026a)
MATLAB Report Generator Version 26.1 (R2026a)
MATLAB Test Version 26.1 (R2026a)
Mapping Toolbox Version 26.1 (R2026a)
Mixed-Signal Blockset Version 26.1 (R2026a)
Model Predictive Control Toolbox Version 26.1 (R2026a)
Model-Based Calibration Toolbox Version 26.1 (R2026a)
Motor Control Blockset Version 26.1 (R2026a)
Navigation Toolbox Version 26.1 (R2026a)
Optimization Toolbox Version 26.1 (R2026a)
Parallel Computing Toolbox Version 26.1 (R2026a)
Partial Differential Equation Toolbox Version 26.1 (R2026a)
Phased Array System Toolbox Version 26.1 (R2026a)
RF Blockset Version 26.1 (R2026a)
RF PCB Toolbox Version 26.1 (R2026a)
RF Toolbox Version 26.1 (R2026a)
ROS Toolbox Version 26.1 (R2026a)
Radar Toolbox Version 26.1 (R2026a)
STM32 Microcontroller Blockset Version 26.1 (R2026a)
Satellite Communications Toolbox Version 26.1 (R2026a)
Sensor Fusion and Tracking Toolbox Version 26.1 (R2026a)
Signal Processing Toolbox Version 26.1 (R2026a)
SimEvents Version 26.1 (R2026a)
Simscape Version 26.1 (R2026a)
Simscape Driveline Version 26.1 (R2026a)
Simscape Electrical Version 26.1 (R2026a)
Simscape Multibody Version 26.1 (R2026a)
Simulink 3D Animation Version 26.1 (R2026a)
Simulink Check Version 26.1 (R2026a)
Simulink Code Inspector Version 26.1 (R2026a)
Simulink Coder Version 26.1 (R2026a)
Simulink Compiler Version 26.1 (R2026a)
Simulink Control Design Version 26.1 (R2026a)
Simulink Coverage Version 26.1 (R2026a)
Simulink Design Optimization Version 26.1 (R2026a)
Simulink Design Verifier Version 26.1 (R2026a)
Simulink Desktop Real-Time Version 26.1 (R2026a)
Simulink FMU Builder Version 26.1 (R2026a)
Simulink Fault Analyzer Version 26.1 (R2026a)
Simulink PLC Coder Version 26.1 (R2026a)
Simulink Real-Time Version 26.1 (R2026a)
Simulink Report Generator Version 26.1 (R2026a)
Simulink Test Version 26.1 (R2026a)
SoC Blockset Version 26.1 (R2026a)
Stateflow Version 26.1 (R2026a)
Statistics and Machine Learning Toolbox Version 26.1 (R2026a)
Symbolic Math Toolbox Version 26.1 (R2026a)
System Composer Version 26.1 (R2026a)
System Identification Toolbox Version 26.1 (R2026a)
UAV Toolbox Version 26.1 (R2026a)
Vehicle Dynamics Blockset Version 26.1 (R2026a)
Vehicle Network Toolbox Version 26.1 (R2026a)
Vision HDL Toolbox Version 26.1 (R2026a)
WLAN Toolbox Version 26.1 (R2026a)
Wavelet Toolbox Version 26.1 (R2026a)
Wireless HDL Toolbox Version 26.1 (R2026a)
Wireless Network Toolbox Version 26.1 (R2026a)
Wireless Testbench Version 26.1 (R2026a)
2) For the immediate, I am trying to import custom gerber file layers (two, one for the top and one for the bottom) and the associated drill file. I am using script files, using the "pcbStack" object. I am able to import those layers successfully, and define a dielectric layer between the two metal layers. I can view that object in a figure and I initially see the feedpoint at (0, 0, 0). I can also see where I want the feedpoint to be, based upon the 3D figure. I (re)define the feedpoint using the following commands:
NBMPA1.FeedDiameter = 1*mm;
NBMPA1.FeedLocations = [45*mm -59.5*mm 2 4];
Obviously, my object name is "NBMPA1". And when I view that in a figure, it seems to properly show the feedpoint connected between the radiator launch feedpoint location I want on layer 2 and ground patch on layer 4. Note that I have a grounded coplanar feedline connected to the quarter-wave monopole radiator, with plated through hole vias defined, to connct the two ground patches on layer 2 (which are on either side of the launch strip) and the ground patch on layer 4. (Very simple geometry.) All seems ok at this juncture in the script.
3) When I try to create a mesh, I get the error:
Some or all parts of one or more metal layers lies outside the board.
Error in em.MeshGeometry/updateMeshForPcbStack
Error in em.MeshGeometry/protectedmesh
Error in
protectedmesh(obj,varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in
mesh(NBMPA1, MaxEdgeLength=5*mm, MinEdgeLength=0.5*mm)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**When I view the object in a figure, feedpoint seems to be within the metal borders on both layers 2 and 4. So I'm confused.
4) I cannot find any documentation on the use of the feedpoint command structure "pb.FeedLocations(1:2) = [x, y];" That is, I don't know what the parathesis structure is/does, which is attached to the function call. Hence, maybe I'm using the incorrect command for the feedpoint? As well, the command "createFeed()" gives me errors:
Unrecognized function or variable 'createFeed'.
createFeed(NBMPA1)
^^^^^^^^^^^^^^^^^^
Regards,
Scott
Umar
Umar 2026년 8월 27일 3:34
Hi @Scott,
Good news — both of your earlier issues are now explained:
createFeed error: That function only works on customAntenna/customAntennaMesh/customAntennaStl — it doesn't exist for pcbStack, so the error was expected. Just drop that line. Your FeedDiameter/FeedLocations code was already the correct way to set a feed on a pcbStack.
The (1:2) syntax: Just normal MATLAB indexing — it overwrites the x,y part of FeedLocations and leaves the layer numbers alone. Your full version ([45*mm -59.5*mm 2 4]) is correct and complete; no need to worry about it.
The real remaining problem is the mesh error, and it's about BoardShape, not your feed placement. Try:
NBMPA1.BoardShape figure show(NBMPA1.BoardShape)
and compare that against your actual board size and your feed/via pad locations. gerberRead doesn't take an outline file, so BoardShape isn't coming from anything you explicitly gave it — I don't have a solid doc reference for exactly how it's derived here, so it's worth just checking directly rather than guessing.
Two likely culprits:
The board shape it inferred is too small — the mesher checks the full pad footprint (center ± radius), so a feed/via can look "inside" in a 3D view but still poke outside the boundary.
If you re-centered the top layer but not the bottom layer by the same amount, the two layers (and the board shape) could be misaligned relative to each other.
If BoardShape looks wrong, just set it explicitly to your real board dimensions:
NBMPA1.BoardShape = antenna.Rectangle(Length=..., Width=..., Center=[...]);
Let me know what show(NBMPA1.BoardShape) looks like next to your actual board — that'll tell us if it's a size issue or an alignment issue.

댓글을 달려면 로그인하십시오.

질문:

2026년 8월 17일 14:28

댓글:

2026년 8월 27일 3:34

Community Treasure Hunt

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

Start Hunting!

Translated by