Anten Paterni bulmak(Matlab)
Bu fonksiyonu ilk olarak Mersin Üniversitesindeki Caner Hocam derste yazmıştı. Kendisine teşekkür ederim.
Burada Matlab ile yazdığım antenin elektromanyetik yayılım şeklini gösteren fonksiyonu yazdım. İntihal yapmadan kullanın.
KODLAR;
function AF = pattern(N,b,d,theta,fig,loop1,loop2,waitsec)
% N number of antenna elements
% b=beta means phase
% d spacing between antenna elements
% theta vary theta in xz plane
% fig true if you want figure
% loop1 true if you want plot for varing beta in loop
% loop1 true if you want polarplot for varing beta in loop
%% robustness
if nargin<1
N=4;
end
if nargin<2
b=pi/2;
end
if nargin<3
d=1/2;
end
if nargin<4
theta=linspace(0,2*pi,1000);
end
if nargin<5
fig=false;
end
if nargin<6
loop1=false;
end
if nargin<7
loop2=false;
end
if nargin<8
waitsec=0;
end
%% basic equation
Kd=2*pi*d;
phi=Kd.*cos(theta)+b;
AF=abs( sin(N.*phi/2)./(N.*sin(phi/2)) ); AF=AF/max(AF);
%% Do you want to figure?
if fig
figure;
%% Do You want to plot for varying beta?
if loop1
subplot(121); p=plot(1, 1);
% n=numel(b);
% seg_size = 500;
% start = 1;
for ix=b
phi=Kd.*cos(theta)+ix;
AF=abs( sin(N.*phi/2)./(N.*sin(phi/2)) ); AF=AF/max(AF);
set(p,'XData',theta*180/pi,...
'YData',AF);
% for ix=1:n if (ix-start > seg_size)
% start = ix-1; p = plot(start,1);
% end set(p,'XData',theta(start:ix)*180/pi,...
% 'YData',AF(start:ix));
% if ~mod(ix,50)
% drawnow;
% end
pause(waitsec)
end
else
subplot(121); plot(theta*180/pi, AF);
end
%% Do You want to polarplot for varying beta?
if loop2
subplot(122); pp=polarplot(1, 1);
% n=numel(b);
% seg_size = 500;
% start = 1;
for ix=b
phi=Kd.*cos(theta)+ix;
AF=abs( sin(N.*phi/2)./(N.*sin(phi/2)) ); AF=AF/max(AF);
set(pp,'ThetaData',theta,...
'RData',AF);
% for ix=1:numel(b)
% if (ix-start > seg_size)
% start = ix-1; pp=polarplot(1, 1);
% end
%
% set(pp,'ThetaData',theta(start:ix),...
% 'RData',AF(start:ix));
%
% if mod(ix,50) == 0
% drawnow;
% end
pause(waitsec)
end
else
subplot(122); polarplot(theta, AF);
end
end
end
TEST KODLARI;
% Uniform linear array antenna matlab
%% Test 1
N=4;
b0=pi/2;
d=1/2; %lambda/2
% rad/pi==degree/180
theta=linspace(0,2*pi,1000);
% pattern(N,b0,d,theta,true); %Valid result
b=linspace(b0,b0+2*pi,numel(theta));
pattern(N,b,d,theta,true,true,true,0.001);
%% Test 2
N=2;
b0=0;
d=1/2;
theta=linspace(0,2*pi,1000);
pattern(N,b0,d,theta,true); %Valid result
%% Test 3
N=2;
b0=pi/2; %b0=-pi/2;
d=1/4;
theta=linspace(0,2*pi,1000);
pattern(N,b0,d,theta,true); %Valid result
%% Test 4 "STANDART End Fire"
N=5;
b0=0.9*pi; %b0=-pi/2;
d=0.45; %d<=0.45
theta=linspace(0,2*pi,1000);
pattern(N,b0,d,theta,true); %Valid result
%% Test 5 "HANSEN-WOODYARD End Fire"
N=5;
b0=0.9*pi; %b0=-pi/2;
d=0.35; %d<=0.4
theta=linspace(0,2*pi,1000);
pattern(N,b0,d,theta,true); %Valid result
Yorumlar
Yorum Gönder