- patternCustom: https://www.mathworks.com/help/antenna/ref/patterncustom.html
- xticks: https://www.mathworks.com/help/matlab/ref/xticks.html
- view: https://www.mathworks.com/help/matlab/ref/view.html
- polarplot: https://www.mathworks.com/help/matlab/ref/polarplot.html
- polaraxes: https://www.mathworks.com/help/matlab/ref/polaraxes.html
How to insert tick and numbers for spherical axes?
1 次查看(过去 30 天)
显示 更早的评论
I've managed to plot my data using patternCustom() function :

I want to add ticks and numbers to the elevation and azimuth polar axes - is that possible?
Thanks.
0 个评论
回答(1 个)
AR
2025-3-24
I understand that you want to add ticks and numbers to the elevation and azimuth in polar axes. The “patternCustom” function generates a 3D Cartesian plot (axes) and to display ticks and labels, manually set them on the Cartesian axes (X and Z axes) to indicate azimuth and elevation, respectively.
Below is an example code for the same:
% Example Data
azimuth = -180:10:180; % Azimuth angles in degrees
elevation = -90:10:90; % Elevation angles in degrees
[Az, El] = meshgrid(azimuth, elevation);
magnitude = abs(cosd(Az)) .* abs(cosd(El));
% Reshape Data for patternCustom
Az = Az(:);
El = El(:);
magnitude = magnitude(:);
% Plot Using patternCustom()
figure;
patternCustom(magnitude, Az, El);
% Access Current Axes
ax = gca;
ax.Visible = 'on'; % Ensure Axes are visible
Setting Azimuth (θ) ticks and labels on the X-axis using "xticks()" and "xticklabels()".
% Set Azimuth (θ) Ticks and Labels (X-Axis)
xticks(-180:45:180); % Set tick positions
xticklabels(string(-180:45:180)); % Set tick labels
Setting Elevation (φ) ticks and labels on the Z-axis using "zticks()" and "zticklabels()".
% Set Elevation (φ) Ticks and Labels (Z-Axis)
zticks(-90:30:90); % Set tick positions
zticklabels(string(-90:30:90)); % Set tick labels
Adjusting the viewing angle using "view()" to make the data more interpretable.
% Set Axis Labels
xlabel('Azimuth (°)');
ylabel('Magnitude');
zlabel('Elevation (°)');
view(135, 30);
grid on; % Show grid for clarity
% Ensure the plot is refreshed
drawnow;
This approach provides a visual representation of azimuth and elevation angles like what you might expect from a polar plot. If true polar plotting is required, consider using MATLAB's polar plotting functions, such as “polarplot” or “polaraxes”, which are specifically designed for polar coordinates.
Refer the below links for more information:
Hope this is helpful!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!