replotting radiation pattern from its txt form
Show older comments
Hello ,I have as simple patch antenna with a radiation pattern shown in the attached photo.
i have its TXT form in the attached txt file called "data_rad.txt"
how can i recreate this plot from the TXT file in matlab.
Thanks
2 Comments
ali
on 8 Dec 2017
hi did you find the solution ?? I need help too :)
Shashank Kulkarni
on 11 Mar 2026 at 11:33
Try the patternCustom function in Antenna Toolbox
https://in.mathworks.com/help/antenna/ref/patterncustom.html
Answers (1)
Mathieu NOE
on 12 Mar 2026 at 9:46
hello
maybe this ? nothing fancy but I just figure out your reference image and the usual elevation angle convention (which is the one used in matlab function sph2cart) differs by a shift of pi/2.
the sphere radius is supposed to be 1 (no data found on this matter).
if you want a smooth sphere plot without the edges see fig 3
filename = "data_rad.txt ";
data = readmatrix(filename,'NumHeaderLines',2); % or readtable or whatever you prefer
% Theta [deg.] Phi [deg.] Abs(Dir.)[dBi ] Abs(Theta)[dBi ] Phase(Theta)[deg.] Abs(Phi )[dBi ] Phase(Phi )[deg.] Ax.Ratio[dB ]
theta = data(:,1)*pi/180; % elevation in radians
theta = pi/2-theta; % /!\ onvention change (from image convention to usual elevation angle convention ,also as per matlab fn)
phi = data(:,2)*pi/180; % azimuth in radians
Ad = data(:,3); % Abs(Dir.)[dBi]
% Convert to Cartesian coordinates
[x, y, z] = sph2cart(phi, theta, 1); % (azimuth TH, elevation PHI, radius R)
figure(1)
scatter3(x,y,z,20,Ad,'filled');
xlabel('X')
ylabel('Y')
zlabel('Z')
axis equal
colormap('jet');
colorbar
figure(2)
tri = convhull([x y z]); % triangle connectivity matrix (could be also
% obtained with delaunay) - but since it's a sphere, I think convhull is better suited.
% tri = delaunay([x y z]); % triangle connectivity matrix (could be also obtained with delaunay)
trisurf(tri,x,y,z,Ad,'facecolor','interp');
xlabel('X')
ylabel('Y')
zlabel('Z')
axis equal
colormap('jet');
colorbar
figure(3)
trisurf(tri,x,y,z,Ad,'facecolor','interp','edgecolor','none');
xlabel('X')
ylabel('Y')
zlabel('Z')
axis equal
colormap('jet');
colorbar
Categories
Find more on Surface and Mesh Plots 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!