![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/924819/image.jpeg)
Radar System PPI polar display
15 views (last 30 days)
Show older comments
Jose Iglesias
on 12 Mar 2022
Commented: William Rose
on 12 Mar 2022
I am trying to plot a radar Plan Position Indicator (PPI) slant range with the following code. This code is describing a scene with a radar at 2 km altitude scanning the area contained in a box. The x axis ranges from -90 to 0 degrees, and to 0 degrees to 90 degrees.The y axis ranges from 2 to 12km and the x axis is in respect 10 km split into two section of 0 to 5 km on either side. I tried this code and it worked and I was able to plot the B-scan slant range and true ground range. However, when I tried to plot the PPI slant range with a polar display which is supposed to look like a traditional radar screen, it looks like lines contained within the radar screen instead of dots representing point locations. I attached the code and the other script which has the two equations being used. The equations are phi = atan(x/y) and rho = sqrt(x^2 +y^2 +(h-H)^2) -(h-0.2). I set the polarplot in terms of phi and rho but my plot looks like lines instead of dots on the polar display. I also included a pic of the scene and my current polar plot. Any suggestions?
Script 1
% x = [5 5 5 5 4 4 4 4 4 3 3 3 3 3 3 0 0 0 0 0 0 2 5 5 5 5 5 5];
% y = [10 9 3 0 10 9 8 3 0 10 9 8 7 3 0 10 6 5 4 3 0 5 10 6 5 4 3 0];
% h = [1.8 2 2 2 2 1.8 2 2 2 2 2 1.8 2 2 2 2 2 1.8 2 2 2 1.8 2 2 1.8 2 2 2];
% phi = [-26.6 -29.1 -59.1 -90 -21.8 -24.0 -26.6 -53.1 -90 -16.7 -18.4 -20.6 -23.2 -45 -90 0 0 0 0 0 0 21.8 26.6 39.8 45 51.3 59.0 90];
% r = [11.32 10.49 6.16 5.39 10.95 10.01 9.17 5.39 4.47 10.63 9.70 8.73 7.87 4.69 3.61 10.20 6.32 5.32 4.47 3.61 2 5.59 11.36 8.06 7.30 6.71 6.16 5.39];
%% build scenario
box_x=[];
box_x=[box_x -5:0.5:5];
box_x=[box_x (zeros(1,21)+5)];
box_x=[box_x 5:-0.5:-5];
box_x=[box_x (zeros(1,21)-5)];
box_y=[];
box_y=[box_y zeros(1,21)];
box_y=[box_y 0:0.5:10];
box_y=[box_y (zeros(1,21)+10)];
box_y=[box_y 10:-0.50:0];
box_z=zeros(1,84);
%%
road_x=[];
road_x=[road_x -5:0.5:5];
road_y=[];
road_y=[road_y zeros(1,21)+3];
road_z=[];
road_z=[road_z (zeros(1,21))];
%%
radio_tower_x=[];
radio_tower_x=[radio_tower_x (zeros(1,31)+1.5)];
radio_tower_y=[];
radio_tower_y=[radio_tower_y (zeros(1,31)+5)];
radio_tower_z=[];
radio_tower_z=[radio_tower_z 0.2:0.01:0.5];
%%
ridgebasef_x=[];
ridgebasef_x=[ridgebasef_x 5:-0.25:0];
ridgebasef_x=[ridgebasef_x 0:-0.25:-5];
ridgebasef_y=[];
ridgebasef_y=[ridgebasef_y (zeros(1,21)+4)];
ridgebasef_y=[ridgebasef_y 4:0.25:9];
ridgebasef_z=[];
ridgebasef_z=[ridgebasef_z (zeros(1,42))];
%%
ridgetop_x=[];
ridgetop_x=[ridgetop_x 5:-0.25:0];
ridgetop_x=[ridgetop_x 0:-0.25:-5];
ridgetop_y=[];
ridgetop_y=[ridgetop_y (zeros(1,21)+5)];
ridgetop_y=[ridgetop_y 5:0.25:10];
ridgetop_z=[];
ridgetop_z=[ridgetop_z (zeros(1,42)+0.2)];
ridgebaseb_x=[];
ridgebaseb_x=[ridgebaseb_x 5:-0.25:0];
ridgebaseb_x=[ridgebaseb_x 0:-0.25:-5];
ridgebaseb_y=[];
ridgebaseb_y=[ridgebaseb_y (zeros(1,21)+6)];
ridgebaseb_y=[ridgebaseb_y 6:0.20:10];
ridgebaseb_z=[];
ridgebaseb_z=[ridgebaseb_z (zeros(1,42))];
% done with Scenario
%% Call conversion to PPI_SR
Radar_x = 0.0;
Radar_y = 0.0;
Radar_z = 2.0;
[box_Az box_Rng] = FN_PPI_SR(box_x,box_y,box_z,Radar_x,Radar_y,Radar_z);
[road_Az road_Rng] = FN_PPI_SR(road_x,road_y,road_z,Radar_x,Radar_y,Radar_z);
[ridgebasef_Az ridgebasef_Rng] = FN_PPI_SR(ridgebasef_x,ridgebasef_y,ridgebasef_z,Radar_x,Radar_y,Radar_z);
[tower_Az tower_Rng] = FN_PPI_SR(radio_tower_x,radio_tower_y,radio_tower_z,Radar_x,Radar_y,Radar_z);
[ridgetop_Az ridgetop_Rng] = FN_PPI_SR(ridgetop_x,ridgetop_y,ridgetop_z,Radar_x,Radar_y,Radar_z);
[ridgebaseb_Az ridgebaseb_Rng] = FN_PPI_SR(ridgebaseb_x,ridgebaseb_y,ridgebaseb_z,Radar_x,Radar_y,Radar_z);
figure(1)
polarplot(box_Az,box_Rng,'k');hold on; %'k' gives black
polarplot(road_Az,road_Rng,'b');%'b' gives blue
polarplot(ridgebasef_Az,ridgebasef_Rng,'.-g');%'.-g' gives dashed green line
polarplot(tower_Az,tower_Rng,'r');%'g' gives red line
polarplot(ridgetop_Az,ridgetop_Rng,'.-c');%'.-c' gives dashed cyan line
polarplot(ridgebaseb_Az,ridgebaseb_Rng,'y');%'y' gives yellow line
hold off;
xlim([-90 90])
ylim([2 12]);
grid on
xlabel('AZIMUTH (deg)')
ylabel('SLANT RANGE (km)')
title('BSCAN (SLANT RANGE)');
legend('FRAME','ROAD','RIDGEBASE-F','TOWER','RIDGETOP','RIDGEBASE-B');
% figure
% hold on
% plot(box_x,box_y,x,y)
% set(gca,'XTickLabel', [-90 -70 -50 -30 -10 0 10 30 50 70 90])
% set(gca, 'YTickLabel', [0 1 2 3 4 5 6 7 8 9 10])
Script 2
function [outaz outR] = FN_PPI_SR(tx,ty,tz,rx,ry,rz)
%UNTITLED2 Summary of this function goes here
% Detailed explanation goes here
outR = sqrt((tx-rx).^2+(ty-ry).^2+(tz-rz).^2)-(tz-0.2);
% x^2 y^2 (h-H)^2
outaz = 57.3*atan((tx-rx)./(ty-ry));
end
0 Comments
Accepted Answer
William Rose
on 12 Mar 2022
Edited: William Rose
on 12 Mar 2022
[Edited: Fixed a few typos in my text below. Code, figure unchanged.]
Angles should be in radians, not degrees, for polarplot().
I have changed atan() to atan2(), which is the better function to use if you have both x and y data.
I have changed the angle range from +-90 degrees to 0..180 degrees.
I use rlim() and thetalim() rather than xlim() and ylim().
I deleted the xlabel(), ylabel() commands since they do not work with polar plots.
I am showing just the ridgetop, road, and tower for simplicity. You can add the rest.
Your way of defining the target location vectors seems cumbersome to me. See how I have done it differently for the road, ridgetop, and tower. My way is clearer and uses a lot fewer lines of code.
I modfied the radius calculation in your function because I think it is a mistake to subtract tz-0.2 from every slant range.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/924819/image.jpeg)
2 Comments
More Answers (0)
See Also
Categories
Find more on Polar 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!