Code covered by the BSD License  

Highlights from
Dipole & Rectangular Aperture antenna pattern

image thumbnail
from Dipole & Rectangular Aperture antenna pattern by Salaheddin Hosseinzadeh
3D Polar plot for various Dipole and Rectangular Aperture antennas.

Dipole_Aperture_Aid(varargin)
function varargout = Dipole_Aperture_Aid(varargin)
% DIPOLE_APERTURE_AID M-file for Dipole_Aperture_Aid.fig
%      DIPOLE_APERTURE_AID, by itself, creates a new DIPOLE_APERTURE_AID or raises the existing
%      singleton*.
%
%      H = DIPOLE_APERTURE_AID returns the handle to a new DIPOLE_APERTURE_AID or the handle to
%      the existing singleton*.
%
%      DIPOLE_APERTURE_AID('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DIPOLE_APERTURE_AID.M with the given input arguments.
%
%      DIPOLE_APERTURE_AID('Property','Value',...) creates a new DIPOLE_APERTURE_AID or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Dipole_Aperture_Aid_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Dipole_Aperture_Aid_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Dipole_Aperture_Aid

% Last Modified by GUIDE v2.5 30-Dec-2010 21:53:47

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Dipole_Aperture_Aid_OpeningFcn, ...
                   'gui_OutputFcn',  @Dipole_Aperture_Aid_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Dipole_Aperture_Aid is made visible.
function Dipole_Aperture_Aid_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Dipole_Aperture_Aid (see VARARGIN)

%%__________________________________________________________________
%%____________________Start of the Program__________________________
%%__________________________________________________________________

%Variable Definition Specially Global and Preset ones
% Some values have default values so that it could be sketch by a single
% click
global PhiMax;
PhiMax = 2*pi;      % set default Phi

global ThetaMax;
ThetaMax = pi;      % set default Theta

global dimension;
dimension = 50;      %set default dimension

global Length
Length=1;            % set default Length
% Choose default command line output for Dipole_Aperture_Aid
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Dipole_Aperture_Aid wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Dipole_Aperture_Aid_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu1
%%____________________ Gather user information for Phi range
global PhiMax
content = get(hObject,'Value');
switch content
    case 1
      PhiMax=2*pi;
       PhiMax 
       
    case 2 
       PhiMax=1.5*pi;
        PhiMax

    case 3  
        PhiMax=pi;
        PhiMax
    
    case 4
        PhiMax=.5*pi;
        PhiMax
        
    otherwise
        disp('input wrong'); %% Otherwise condition will never happend
end


% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on selection change in popupmenu2.
function popupmenu2_Callback(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns popupmenu2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from popupmenu2
%%____________ Gather user information for Theta ____________________
global ThetaMax
content = get(hObject,'Value'); % returned value is Theta angle , stored in content
switch content
    case 1
        ThetaMax=pi;
        ThetaMax
    case 2
        ThetaMax=.75*pi;
        ThetaMax
    case 3
        ThetaMax=.5*pi;
        ThetaMax
    otherwise
        disp('Non Above , actually this condition will never ever happen')
end


% --- Executes during object creation, after setting all properties.
function popupmenu2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popupmenu2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: popupmenu controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
%%____________ Returns the dimension of phi & theta matrix assigned by user
global dimension
dimension=str2double(get(hObject,'String'));
dimension=floor(dimension);    % as floats arent accepted dimension floored for example 

%if dimension ( announced as Quality ) = 112.5 it's gonna turn into 112


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%%_____________ Data Generation Button & its duties listed below________________
%%__ 1_Validating Dimension ( Zero,NaN,Inf ) gonna be amende, if necessery

global ThetaMax
global PhiMax
global dimension
global phi
global theta


if (dimension == 0)   % IF . gonna check the dimension validity
    dimension=50
    disp('Zero precision is not accepted , its set to default of 50')
    %dimension     %to display the value   
elseif(isnan(dimension)==1)
    disp('NaN Dimension is not accepted , its set to default of 50')
    dimension= 50
elseif(isinf(dimension)==1)
    disp('Infinite Dimension is not accepted , its set ot default of 50')
    dimension=50
elseif(dimension < 0)
    disp('Negative precision is not accepted , its set to default of 50')
    dimension=50
elseif(dimension < 40)
    disp('!This precision is not recommended!, it`d better increase it.')

end


phi= linspace(0,PhiMax,dimension);    %%% Generating phi & theta related to 
theta= linspace(0,ThetaMax,dimension); %% user input

%%_ This condition is jut to make 100 % sure , or else this will not happend 
if(size(phi)==size(theta)) 
    disp('Data Generation Successful')
else
    disp('Data Generation Failed , Try Again This messege will never shows up , unless you do some magic , LOL')
end



function edit2_Callback(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double

%%___________ Requesting and validating Antenna Length ___________________
global Length
Length=str2double(get(hObject,'String'));

%global Length
if(isnan(Length)== 1 )      %  Length validity
    disp('Attention!! Length is NaN')
    disp('This will illustrate infinitesimal Dipole Pattern!')
    Length = eps 
elseif( isinf(Length)== 1)
    disp('Attention!! Length is Infinite')
    disp('This will illustrate Infinite Dipole Pattern!')
    Length = Inf
elseif(Length == 0)
    disp('Length is Zero')
    disp('This will illustrate infinitesimal Dipole Pattern')
    Length = eps
elseif(Length == -1)
    disp('Attention!! Length is MINUS !! Length changed to default value 1')
    length=1
    
end
%length=str2num(Length);
    



% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),...
        get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%___________________ sketch useing Mesh _____________________
global phi 
global theta
global Length
global R
global x
global y
global z
[THETA,PHI]=meshgrid(theta,phi);
R=abs((cos(pi.*Length.*cos(THETA))- cos(pi.*Length))./(sin(THETA)));
x=R.*sin(THETA).*cos(PHI);
y=R.*sin(THETA).*sin(PHI);
z=R.*cos(THETA);
%figure
mesh(x,y,z);
%clear all
set(gca,'PlotBoxAspectRatio',[1,1,1])
axis equal;
xlabel('Axis X');
ylabel('Axis Y');
zlabel('Axis Z');
title(['L =  ',num2str(Length),'Lambda'])

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%%__________________ Sketch using Plot3 ___________________________
global phi 
global theta
global Length
global R
global x
global y
global z
[THETA,PHI]=meshgrid(theta,phi);
R=abs((cos(Length.*pi.*cos(THETA))- cos(Length.*pi))./(sin(THETA)));
x=R.*sin(THETA).*cos(PHI);
y=R.*sin(THETA).*sin(PHI);
z=R.*cos(THETA);
%figure
plot3(x,y,z);
%clear all
set(gca,'PlotBoxAspectRatio',[1,1,1])
axis equal;
xlabel('Axis X');
ylabel('Axis Y');
zlabel('Axis Z');
title(['L =  ',num2str(Length),'Lambda'])

% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%______________________ Sketch Using Surf_________________________
global phi 
global theta
global Length
global R
global x
global y
global z
[THETA,PHI]=meshgrid(theta,phi);
R=abs((cos(Length.*pi.*cos(THETA))- cos(Length.*pi))./(sin(THETA)));
x=R.*sin(THETA).*cos(PHI);
y=R.*sin(THETA).*sin(PHI);
z=R.*cos(THETA);
%Length
%figure
surf(x,y,z);
%clear all
set(gca,'PlotBoxAspectRatio',[1,1,1])
axis equal;
xlabel ('Axis X');
ylabel ('Axis Y');
zlabel ('Axis Z');
title(['L =  ',num2str(Length),'Lambda'])
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%________________Sketch 2Dimension E Plane Using Polar____________________
global phi 
global theta
global Length
global r

r=abs((cos(Length.*pi.*cos(phi))- cos(Length.*pi))./(sin(phi)));
%figure
polar(phi,r);
axis equal
title(['L =  ',num2str(Length),'Lambda'])
%clear all



function edit3_Callback(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text
 global ap_a; 
 ap_a = str2double(get(hObject,'String')); % returns contents of edit3 as a double


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),...
        get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit6 as text
global ap_b;
ap_b = str2double(get(hObject,'String'));% returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), ...
        get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% ploting aperture antenna 3D 
global ap_a;
global ap_b;
global phi;
global theta;
[Phi,Theta]=meshgrid(phi,theta);
% ap_a & ap_b are dimensions of the notch
% U = sin(theta).cos(phi)   v = sin(theta).sin(phi) for 3D plot
U = sin(Theta).*cos(Phi);
V = sin(Theta).*sin(Phi);
B=2*pi;
% u & v both in lowercase for 2D plot
u = sin(theta).*cos(0);
v = sin(theta).*sin(0);
% rho is 2D polar pattern 
rho = abs (sinc(B*ap_a/2.*u).*sinc(B*ap_b/2.*v));
% E for 3D pattern
E = abs( sinc(B*ap_a/2.*U).*sinc(B*ap_b/2.*V));
x = E.*cos(Phi).*sin(Theta);
y = E.*sin(Phi).*sin(Theta);
z = E.*cos(Theta);
% polar plot 
plot(rho.*sin(phi),rho.*cos(phi));
set(gca,'PlotBoxAspectRatio',[1,3,1])
xlabel('Axis X');
ylabel('Axis Y');
title(['Rectangular Aperture Antenna Cross Section for '...
    ,num2str(ap_a),',',num2str(ap_b),' Lambda'])

figure('Name','3D Aperture Plot');
mesh(x,y,z)
set(gca,'PlotBoxAspectRatio',[.5,.5,2])
xlabel('Axis X');
ylabel('Axis Y');
zlabel('Axis Z');
title(['Rectangular Aperture Antenna '...
    ,num2str(ap_a),',',num2str(ap_b),'Lambda'])

Contact us