function polarplotdb(theta,rho,line_style)
if nargin < 1
error('Requires 2 or 3 input arguments!');
elseif nargin == 2
if ischar(rho)
line_style = rho;
rho = theta;
[mr,nr] = size(rho);
if mr == 1
theta = 1:nr;
else
th = (1:mr)';
theta = th(:,ones(1,nr));
end
else
line_style = 'auto';
end
elseif nargin == 1
line_style = 'auto';
rho = theta;
[mr,nr] = size(rho);
if mr == 1
theta = 1:nr;
else
th = (1:mr)';
theta = th(:,ones(1:nr));
end
end
if ischar(theta) || ischar(rho)
error('Input arguments must be numeric.');
end
if ~isequal(size(theta),size(rho))
error('THETA and RHO must be the same size.');
end
% get old state
cax = newplot;
next = lower(get(cax,'NextPlot'));
hold_state = ishold;
% get x-axis text color so grid is in same color
tc = get(cax,'xcolor');
ls = get(cax,'gridlinestyle');
% Hold on to current Text defaults,reset them to the
% Axes' font attributes so tick marks use them
fAngle = get(cax,'DefaultTextFontAngle');
fName = get(cax,'DefaultTextFontName');
fSize = get(cax,'DefaultTextFontSize');
fWeight = get(cax,'DefaultTextFontWeight');
fUnits = get(cax,'DefaultTextUnits');
set(cax,'DefaultTextFontAngle',get(cax,'FontAngle'),...
'DefaultTextFontName',get(cax,'FontName'),...
'DefaultTextFontSize',get(cax,'FontSize'),...
'DefaultTextFontWeight',get(cax,'FontWeight'),...
'DefaultTextUnits','data');
% make a radial grid
hold on;
maxrho = 1;
hhh = plot([-maxrho -maxrho maxrho maxrho],[-maxrho maxrho maxrho -maxrho]);
set(gca,'dataaspectratio',[1 1 1],'plotboxaspectratiomode','auto');
v = [get(cax,'xlim') get(cax,'ylim')];
ticks = sum(get(cax,'ytick')>=0);
delete(hhh);
% check radial limits and ticks
rmin = 0;rmax = v(4);rticks = max(ticks-1,2);
if rticks > 5 % see if we can reduce the number
if rem(rticks,2) == 0
rticks = rticks/2;
elseif rem(rticks,3) == 0
rticks = rtick/3;
end
end
% only do grids if hold is off
if ~hold_state
%define a circle
th = 0:pi/50:2*pi;
xunit = cos(th);
yunit = sin(th);
% now really force points on x/y axes to lie on them exactly
inds = 1:(length(th)-1)/4:length(th);
xunit(inds(2:2:4)) = zeros(2,1);
yunit(inds(1:2:5)) = zeros(3,1);
% plot background if necessary
if ~ischar(get(cax,'color'))
patch('xdata',xunit*rmax,'ydata',yunit*rmax,...
'edgecolor',tc,'facecolor',get(gca,'color'),...
'handlevisibility','off');
end
% draw radial circle with dB ticks
c82 = cos(82*pi/180);
s82 = sin(82*pi/180);
rinc = (rmax-rmin)/rticks;
tickdB = -10*(rticks-1); % the innermost tick dB value
for i = (rmin + rinc):rinc:rmax
hhh = plot(xunit*i,yunit*i,ls,'color',tc,'linewidth',1,...
'handlevisibility','off');
text((i+rinc/20)*c82*0,-(i+rinc/20)*s82,...
['' num2str(tickdB) 'dB'],'verticalalignment','bottom',...
'handlevisibility','off');
tickdB = tickdB + 10;
end
set(hhh,'linestyle','-') % make outer circle solid
% plot spokes
th = (1:6)*2*pi/12;
cst = cos(th);
snt = sin(th);
cs = [-cst;cst];
sn = [-snt;snt];
plot(rmax*cs,rmax*sn,ls,'color',tc,'linewidth',1,...
'handlevisibility','off')
% annotate spokes in degrees
rt = 1.1*rmax;
for i = 1:length(th)
text(rt*cst(i),rt*snt(i),int2str(i*30),...
'horizontalalignment','center',...
'handlevisibility','off');
if i == length(th)
loc = int2str(0);
else
loc = int2str(180+i*30);
end
text(-rt*cst(i),-rt*snt(i),loc,'horizontalalignment','center',...
'handlevisibility','off')
end
% set view to 2-D
view(2);
% set axis limits
axis(rmax*[-1 1 -1.15 1.15]);
end
% Reset defaults
set(cax,'DefaultTextFontAngle',fAngle,...
'DefaultTextFontName',fName,...
'DefaultTextFontSize',fSize,...
'DefaultTextFontWeight',fWeight,...
'DefaultTextUnits',fUnits);
% Transfrom data to dB scale
rmin = 0; rmax = 1;
rinc = (rmax-rmin)/rticks;
rhodb = zeros(1,length(rho));
for i = 1:length(rho)
if rho(i)==0
rhodb(i) = 0;
else
rhodb(i)=rmax+2*log10(rho(i))*rinc;
end
if rhodb(i)<=0
rhodb(i)=0;
end
end
% transform data to Cartesian coordinates
xx = rhodb.*cos(theta);
yy = rhodb.*sin(theta);
% plot data on top of grid
if strcmp(line_style,'auto')
q = plot(xx,yy);
else
q = plot(xx,yy,line_style);
end
if nargout > 0
hpol = q;
end
if ~hold_state
set(gca,'dataaspectratio',[1 1 1]);axis off; set(cax,'NextPlot',next);
end
set(get(gca,'xlabel'),'visible','on');
set(get(gca,'ylabel'),'visible','on');
end
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
相控阵波束扫描“动图”的Matlab仿真.rar (2个子文件)
相控阵波束扫描“动图”的Matlab仿真
figPattern.m 783B
polarplotdb.m 5KB
共 2 条
- 1
资源评论
- 巴蜀明月2023-07-26简单明了地展示了相控阵波束扫描的过程,非常易于理解。
- Jaihwoe2023-07-26这个文件很有用,通过Matlab仿真展示了相控阵波束扫描的原理。
- chenbtravel2023-07-26通过这个文件,我对相控阵波束扫描有了更清晰的认识,感觉收获很大。
- 江水流春去2023-07-26这个文件提供了一个很好的学习资源,可以帮助我们更好地了解相控阵技术。
- 张匡龙2023-07-26这个文件的仿真结果很真实,让人对相控阵波束扫描的效果有了更直观的了解。
zm77
- 粉丝: 3
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功