How to use antenna toolbox with a measured antenna ?
Show older comments
Hello !
I am trying to plot an antenna pattern from in situ real measurements of an antenna. My measurements comprise X, Y Z in m and the measured attenuation in dB.
After conversion into azimuth and elevation, unfortunately, this does not seem compatible with either measuredAntenna or patterncustom.
With patterncustom I get the following error :
Error filling holes for shared_channel:patternCustom:RepeatedPoints.
Floating point numbers are not allowed as holes. They should be
converted to character vectors.
With measured antenna, MagE I do not have, as I only have the measured attenuation...
Anyway to get my antenna plots (3D and sections) from my measurements ?
Thanks in advance,
Kindly,
4 Comments
Ganapathi Subramanian R
on 7 May 2024
What do you mean by attentuation here and do you have any other data related to directivity?
Félix
on 7 May 2024
Ganapathi Subramanian R
on 9 May 2024
Hi Felix,
According to recent MATLAB documentation, the 'patternCustom' function requires antenna directivity, E-fields, H-fields, or power of an antenna or array as input for 'magE' parameter . I suggest you to transform the attentuation data into directivity by finding a correlation between the observed attentuation and directivity.
For further information regarding 'patternCustom' function, please refer to the below documentation.
Félix
on 14 May 2024
Answers (2)
Pooja Kumari
on 9 May 2024
Hi Felix,
I unserstand you are trying to plot an antenna pattern from in situ real measurements of an antenna. You are facing "Error filling holes for shared_channel:patternCustom:RepeatedPoints.Floating point numbers are not allowed as holes. They should be converted to character vectors." error using Pattern Custom function.
If you have attenuation in dB (Attenuation), you can convert it to a relative magnitude scale by assuming that the attenuation is relative to the maximum signal strength you measured or a known reference.
I think the error will be resolved when the parameters are passed in the correct order as follows:
patternCustom(magE, theta, phi);
For more information on Pattern Custom function, you can refer to the below documentation:
Shashank Kulkarni
on 18 May 2026 at 5:57
Edited: Walter Roberson
on 18 May 2026 at 7:49
The problem: You have antenna measurements as X, Y, Z positions with signal attenuation, but both patternCustom and measuredAntenna expect angular data — not Cartesian coordinates.
Why you got errors:
- patternCustom expects theta and phi angles (spherical coordinates in degrees), not X/Y/Z positions. The "RepeatedPoints" error occurs when it can't interpret your inputs as a valid angular grid.
- measuredAntenna expects a Direction matrix with columns [azimuth, elevation, radius] in degrees/meters — again, not Cartesian X/Y/Z.
What you need to do:
1. Convert your X/Y/Z positions to angles. Compute the distance R from the origin to each point, then derive theta (angle from the vertical axis) and phi (angle in the horizontal plane) using inverse trig
functions.
2. Convert attenuation to a pattern quantity. Flip the sign (less attenuation = more gain), then normalize so the peak is 0 dB. This gives you a relative radiation pattern.
3. For patternCustom: Pass the converted pattern values, theta angles, and phi angles — all as vectors of the same length. Alternatively, interpolate onto a regular angular grid and pass as a matrix with
theta and phi vectors.
4. For measuredAntenna with txsite: Interpolate your data onto a regular azimuth/elevation grid. Set E = [] and populate Directivity. Note that txsite requires a specific internal data ordering — the
Direction matrix must use meshgrid-default ordering (no transpose), while the Directivity values must be transposed before flattening.
% === Your measured data ===
% x, y, z: measurement positions (meters)
% atten_dB: measured attenuation at each point (dB)
% Step 1: Convert Cartesian to spherical angles
R = sqrt(x.^2 + y.^2 + z.^2);
theta_meas = rad2deg(acos(z ./ R)); % theta: 0=zenith, 90=horizon
phi_meas = rad2deg(atan2(y, x)); % phi: angle in x-y plane
% Step 2: Convert attenuation to relative pattern
patternData_dB = -atten_dB;
patternData_dB = patternData_dB - max(patternData_dB);
% Step 3: Visualize with patternCustom (all vectors, same length)
figure;
patternCustom(patternData_dB, theta_meas, phi_meas);
% === To create measuredAntenna for txsite/rxsite ===
% Interpolate onto regular az/el grid
az = -180:5:180; el = -90:5:90;
az_meas = rad2deg(atan2(y, x));
el_meas = rad2deg(asin(z ./ R));
[azGrid, elGrid] = meshgrid(az, el);
F = scatteredInterpolant(az_meas(:), el_meas(:), patternData_dB(:), "natural", "nearest");
patAzEl = F(azGrid, elGrid); % Nel-by-Naz
% Direction: el-fast (NO transpose — required for txsite)
[phi_d, elv_d] = meshgrid(az, el);
numPoints = numel(phi_d);
R_far = max(R);
Direction = [phi_d(:) elv_d(:) R_far*ones(numPoints, 1)];
% Directivity: az-fast (transpose then flatten)
D = patAzEl'; D = D(:);
freq = 2.4e9; % your measurement frequency
mAnt = measuredAntenna( ...
E = [], ...
Directivity = D, ...
Direction = Direction, ...
FieldFrequency = freq, ...
Azimuth = az, ...
Elevation = el);
% Use with txsite
tx = txsite(Antenna=mAnt, TransmitterFrequency=freq, ...
TransmitterPower=10, AntennaHeight=30);
coverage(tx, SignalStrengths=[-60 -70 -80 -90], MaxRange=5000);
Categories
Find more on Pattern Data Integration and Visualization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!