image thumbnail

Array Factor

by

 

Array Factor for dipoles. Adjustable number of elements, progressive phase, and separation distance.

ArrayFactor(varargin)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
%   Author: Electromagnetizery @ University of Hawaii
%   Date: 9/24/2012
%   You must obtain my permission to use.
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function varargout = ArrayFactor(varargin)
% ArrayFactor MATLAB code for ArrayFactor.fig
%      ArrayFactor, by itself, creates a new ArrayFactor or raises the existing
%      singleton*.
%
%      H = ArrayFactor returns the handle to a new ArrayFactor or the handle to
%      the existing singleton*.
%
%      ArrayFactor('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in ArrayFactor.M with the given input arguments.
%
%      ArrayFactor('Property','Value',...) creates a new ArrayFactor or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ArrayFactor_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ArrayFactor_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 ArrayFactor

% Last Modified by GUIDE v2.5 24-Sep-2012 18:57:35

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ArrayFactor_OpeningFcn, ...
                   'gui_OutputFcn',  @ArrayFactor_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 ArrayFactor is made visible.
function ArrayFactor_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 ArrayFactor (see VARARGIN)

clc;
psi = 0;        % progressive phase shift
handles.psi=psi;
N=2;            %elements
handles.N=N;
lambda=1;       % wavelength
d=lambda/2;     % distance between elements
handles.d=d;
NewPlot(handles)

% Choose default command line output for ArrayFactor
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = ArrayFactor_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 button press in PsiUp.
function PsiUp_Callback(hObject, eventdata, handles)
% hObject    handle to PsiUp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.psi=handles.psi+10;
guidata(hObject, handles);
NewPlot(handles)


% --- Executes on button press in PsiDown.
function PsiDown_Callback(hObject, eventdata, handles)
% hObject    handle to PsiDown (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.psi=handles.psi-10;
guidata(hObject, handles);
NewPlot(handles)


% --- Executes on button press in NUp.
function NUp_Callback(hObject, eventdata, handles)
% hObject    handle to NUp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.N=handles.N+1;
guidata(hObject, handles);
NewPlot(handles)



% --- Executes on button press in NDown.
function NDown_Callback(hObject, eventdata, handles)
% hObject    handle to NDown (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.N=handles.N-1;
guidata(hObject, handles);
NewPlot(handles)

% --- Executes on button press in dUp.
function dUp_Callback(hObject, eventdata, handles)
% hObject    handle to dUp (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.d=handles.d+.125;
guidata(hObject, handles);
NewPlot(handles)


% --- Executes on button press in dDown.
function dDown_Callback(hObject, eventdata, handles)
% hObject    handle to dDown (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
handles.d=handles.d-.125;
guidata(hObject, handles);
NewPlot(handles)


function NewPlot(handles)

N=handles.N;
psi=handles.psi;
n=0:N-1;
lambda=1;
B=2*pi/lambda;
d=handles.d;
AF = zeros(1,360);

for phi=1:360
    CHI=B*d*cos(phi*pi/180)-psi*pi/180;
    AF(phi) = real(sum(exp(1i*n*CHI)));
end

polar((1:360)*(pi/180),AF);
stri = sprintf('N= %i, PSI= %i Deg, d= %.2f Lambda',handles.N,handles.psi,handles.d);
title(stri);

Contact us