%**************************************************************************
% polar_dB(theta,rho,rmin,rmax,rticks,line_style)
%**************************************************************************
% POLAR_DB is a MATLAB function that plots 2-D patterns in
% polar coordinates where:
% 0 <= THETA (in degrees) <= 360
% -infinity < RHO (in dB) < +infinity
%
% Input Parameters Description
% ----------------------------
% - theta (in degrees) must be a row vector from 0 to 360 degrees
% - rho (in dB) must be a row vector
% - rmin (in dB) sets the minimum limit of the plot (e.g., -60 dB)
% - rmax (in dB) sets the maximum limit of the plot (e.g., 0 dB)
% - rticks is the # of radial ticks (or circles) desired. (e.g., 4)
% - linestyle is solid (e.g., '-') or dashed (e.g., '--')
%
% Credits:
% S. Bellofiore
% S. Georgakopoulos
% A. C. Polycarpou
% C. Wangsvick
% C. Bishop
%
% Tabulate your data accordingly, and call polar_dB to provide the
% 2-D polar plot
%
% Note: This function is different from the polar.m (provided by
% MATLAB) because RHO is given in dB, and it can be negative
%-----------------------------------------------------------------------------
function hpol = polar_dB(theta,rho,rmin,rmax,rticks,line_style)
% Convert degrees into radians
theta = theta * pi/180;
% Font size, font style and line width parameters
font_size = 16;
font_name = 'Times';
line_width = 1.5;
if nargin < 5
error('Requires 5 or 6 input arguments.')
elseif nargin == 5
if isstr(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 isstr(theta) | isstr(rho)
error('Input arguments must be numeric.');
end
if any(size(theta) ~= size(rho))
error('THETA and RHO must be the same size.');
end
% get hold 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');
% 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');
set(cax, 'DefaultTextFontAngle', get(cax, 'FontAngle'), ...
'DefaultTextFontName', font_name, ...
'DefaultTextFontSize', font_size, ...
'DefaultTextFontWeight', get(cax, 'FontWeight') )
% only do grids if hold is off
if ~hold_state
% make a radial grid
hold on;
% v returns the axis limits
% changed the following line to let the y limits become negative
hhh=plot([0 max(theta(:))],[min(rho(:)) max(rho(:))]);
v = [get(cax,'xlim') get(cax,'ylim')];
ticks = length(get(cax,'ytick'));
delete(hhh);
% check radial limits (rticks)
if rticks > 5 % see if we can reduce the number
if rem(rticks,2) == 0
rticks = rticks/2;
elseif rem(rticks,3) == 0
rticks = rticks/3;
end
end
% 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)];
xunits(inds(2:2:4)) = zeros(2,1);
yunits(inds(1:2:5)) = zeros(3,1);
rinc = (rmax-rmin)/rticks;
% label r
% change the following line so that the unit circle is not multiplied
% by a negative number. Ditto for the text locations.
for i=(rmin+rinc):rinc:rmax
is = i - rmin;
plot(xunit*is,yunit*is,'-','color',tc,'linewidth',0.5);
text(0,is+rinc/20,[' ' num2str(i)],'verticalalignment','bottom' );
end
% plot spokes
th = (1:6)*2*pi/12;
cst = cos(th); snt = sin(th);
cs = [-cst; cst];
sn = [-snt; snt];
plot((rmax-rmin)*cs,(rmax-rmin)*sn,'-','color',tc,'linewidth',0.5);
% plot the ticks
george=(rmax-rmin)/30; % Length of the ticks
th2 = (0:36)*2*pi/72;
cst2 = cos(th2); snt2 = sin(th2);
cs2 = [(rmax-rmin-george)*cst2; (rmax-rmin)*cst2];
sn2 = [(rmax-rmin-george)*snt2; (rmax-rmin)*snt2];
plot(cs2,sn2,'-','color',tc,'linewidth',0.15); % 0.5
plot(-cs2,-sn2,'-','color',tc,'linewidth',0.15); % 0.5
% annotate spokes in degrees
% Changed the next line to make the spokes long enough
rt = 1.1*(rmax-rmin);
for i = 1:max(size(th))
text(rt*cst(i),rt*snt(i),int2str(abs(i*30-90)),'horizontalalignment','center' );
if i == max(size(th))
loc = int2str(90);
elseif i*30+90<=180
loc = int2str(i*30+90);
else
loc = int2str(180-(i*30+90-180));
end
text(-rt*cst(i),-rt*snt(i),loc,'horizontalalignment','center' );
end
% set viewto 2-D
view(0,90);
% set axis limits
% Changed the next line to scale things properly
axis((rmax-rmin)*[-1 1 -1.1 1.1]);
end
% Reset defaults.
set(cax, 'DefaultTextFontAngle', fAngle , ...
'DefaultTextFontName', font_name, ...
'DefaultTextFontSize', fSize, ...
'DefaultTextFontWeight', fWeight );
% transform data to Cartesian coordinates.
% changed the next line so negative rho are not plotted on the other side
for i = 1:length(rho)
if (rho(i) > rmin)
if theta(i)*180/pi >=0 & theta(i)*180/pi <=90
xx(i) = (rho(i)-rmin)*cos(pi/2-theta(i));
yy(i) = (rho(i)-rmin)*sin(pi/2-theta(i));
elseif theta(i)*180/pi >=90
xx(i) = (rho(i)-rmin)*cos(-theta(i)+pi/2);
yy(i) = (rho(i)-rmin)*sin(-theta(i)+pi/2);
elseif theta(i)*180/pi < 0
xx(i) = (rho(i)-rmin)*cos(abs(theta(i))+pi/2);
yy(i) = (rho(i)-rmin)*sin(abs(theta(i))+pi/2);
end
else
xx(i) = 0;
yy(i) = 0;
end
end
% 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
axis('equal');axis('off');
end
% reset hold state
if ~hold_state, set(cax,'NextPlot',next); end
没有合适的资源?快使用搜索试试~ 我知道了~
Matlab实现天线场图、波瓣图
共23个文件
m:21个
png:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 183 浏览量
2022-07-06
22:14:46
上传
评论 1
收藏 30KB ZIP 举报
温馨提示
1.版本:matlab2019a,不会运行可私信 2.领域:基础教程 3.内容:Matlab实现天线场图、波瓣图 4.适合人群:本科,硕士等教研学习使用
资源推荐
资源详情
资源评论
收起资源包目录
Matlab实现天线场图、波瓣图 上传.zip (23个子文件)
10元边射D计算.m 350B
main1.m 1KB
huan_antenna.m 288B
10元切比雪夫最优边射阵方向图.m 272B
电流均匀分布偶极子.m 1KB
Untitled3.m 755B
偶极子.m 861B
polar_dB.m 6KB
环天线.m 596B
轴向模螺旋天线.m 329B
10元切比雪夫最优边射阵方向图2.m 893B
polardb.m 5KB
电偶极子等效长度.m 296B
天线
N_element_broadside.m 867B
10元边射二项式分布2.m 868B
main2.m 1KB
轴向模螺旋方向性.m 422B
4.png 8KB
dipol_iequal.m 246B
dipol.m 260B
10元边射二项式分布.m 254B
er_yuan_zhen.m 756B
3.png 8KB
共 23 条
- 1
资源评论
- m0_621284172023-07-06终于找到了超赞的宝藏资源,果断冲冲冲,支持!
天天Matlab科研工作室
- 粉丝: 2w+
- 资源: 7251
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功