function varargout = antenne(varargin)
% ANTENNE M-file for antenne.fig
% ANTENNE, by itself, creates a new ANTENNE or raises the existing
% singleton*.
%
% H = ANTENNE returns the handle to a new ANTENNE or the handle to
% the existing singleton*.
%
% ANTENNE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in ANTENNE.M with the given input arguments.
%
% ANTENNE('Property','Value',...) creates a new ANTENNE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before antenne_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to antenne_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help antenne
% Last Modified by GUIDE v2.5 15-Dec-2006 18:41:35
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @antenne_OpeningFcn, ...
'gui_OutputFcn', @antenne_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 antenne is made visible.
function antenne_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 antenne (see VARARGIN)
% Choose default command line output for antenne
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes antenne wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = antenne_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;
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
% --- 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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
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
% --- 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
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
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)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
L=str2double(get(handles.edit1,'string'));
Z=str2double(get(handles.edit2,'string'));
if (isnan(L) | isnan(Z))==0
if L<=0 | real(Z)<0 | ~isreal(L)
errordlg('Les valeurs doivent tre positives');
else
fig=handles.axes1;ax=handles.axes2;
[pt,ou,he,d]=calantenne(L,Z,fig,ax);
set(handles.text15,'string',num2str(pt));
set(handles.text16,'string',num2str(ou));
set(handles.text17,'string',num2str(he));
set(handles.text18,'string',num2str(d));
axes(ax);
cla
end
else
errordlg('Les donnes doivent tre des valeurs');
end
% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on mouse press over figure background.
function figure1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on key press over edit1 with no controls selected.
function edit1_KeyPressFcn(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)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- Executes on key press over edit2 with no controls selected.
function edit2_KeyPressFcn(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)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over edit1.
function edit1_ButtonDownFcn(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)
% --- Executes during object creation, after setting all properties.
function text1_CreateFcn(hObject, eventdata, handles)
% hObject handle to text1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over text1.
function text1_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to text1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [pt,ou,he,d]=calantenne(n1,alpha1,fig,ax);
% Le programme trace le diagramme de rayonnement pour une antenne
% de longueur L=n*lambda ,(lambda est la longueur d'onde
% l'antenne est ferme sur une impedence Zl=alpha*Zc
% alpha peut tre complexe et Zc est l'impedence caracterestique
syms n alphaa t
gama=sym('(alphaa*cos(2*pi*n1)+i*sin(2*pi*n1))/(cos(2*pi*n1)+i*alphaa*sin(2*pi*n1))');
gama1=limit(gama,alphaa,alpha1);
gama1=eval(gama1);
I0=limit(1+exp(i*4*pi*n1)*(1-alphaa)/(1+alphaa),alphaa,alpha1);
im=eval(int(I0*(cos(2*pi*n)-i*gama1*sin(2*pi*n)),n,0,n1));
IM=abs(I0*(cos(2*pi*n)-i*gama1*sin(2*pi*n)));
I=int(cos(t)*I0*(cos(2*pi*n)-i*gama1*sin(2*pi*n))*exp(i*2*pi*n*sin(t)),n,0,n1);
barr(5000,ax);
n=0:n1/1000:n1;
IM=eval(IM);
IM=max(IM);
IM=IM(1,1);
he=round(100*abs(im)/IM);
clear im n alphaa gama I0 gama1
dp= 47.1239*abs(I)^2;
% | 15*pi
dpt=6.2832*cos(t)*dp;
% | 2*pi
c=1;
for t=-pi/2+.1:.1:pi/2-.1;
p(1,c)=eval(dpt);
dpp(1,c)=eval(dp);
c=c+1;
end
t=-pi/2+.1:.1:pi/2-.1;
pt=trapz(t,p);
d=4*pi*max(dpp)/pt;
pt=round(10*pt/IM^2)/10;
clear dp p dpp dpt
barr(15000,ax);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
c=1;
for t=0:.01:2*pi-.01;
y(1,c)=abs(eval(I));
c=c+1;
end
clear c I
barr(20000,ax);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
t=0:.01:2*pi-.01;
[m,indice]=max(y(1,1:157));
% | round(100*pi/2)
j1=find(y(1,indice:157)<= m/sqrt(2))+indice-1;j1=j1(1,1);
j2=indice+1-find(y(1,indice:-1:1)<= m/sqrt(2));if(length(j2)>=1) j2=j2(1,1);end
ou=t(j1)-t(j2);
if isempty(j2) % | round(300*pi/2)
j2=629-find(y(1,628:-1:471)<= m/sqrt(2));j2=j2(1,1);
ou=t(j1)-t(j2)+2*pi;
end
ou=round(10*rad2deg(ou))/10;
y=y/m;
barr(50000,ax);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
axes(fig);
cla
hold on
polar(t,y)
[x,z]=scircle1(0,0,1);
plot(x,z,':k');
plot(x/sqrt(2),z/sqrt(2),':k');
clear x z m y
polar([t(indice) t(indice)],[0 1.4],'--r');
text(1.1*cos(t(indice)),sin(t(indice)),[num2str(round((90-rad2deg(t(indice))))),'']);
polar([t(j1) t(j1)],[0 1.4],'-m');
polar([t(j2) t(j2)],[0 1.4],'-m');
grid on
axis equal
clear j1 j2 t indice
barr(100000,ax);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function barr(r,ax);
axes(ax);
cla
hold on
plot(1:100000,[10*randn(1,r) zeros(1,100000-r)]);
pause(.01);
% --- Executes on button press in togglebutton2.
function togglebutton2_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton2
% --- Executes on button press in togglebutton3.
function togglebutton3_Callback(hObject, eventdata, handles)
% hObject handle to togglebutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of togglebutton3
% Zakaria Rostom