├── README.md ├── broadside_endfire ├── Comparison.m ├── README.md ├── binomial.m ├── null_spacing.m ├── null_spacing_Comparison.m ├── triangular.m └── uniform.m ├── chebyshev ├── README.md ├── chebysheff.m └── figs │ └── 6_element_Cheby_2.jpg ├── dipole ├── README.md ├── center_fed_Vertical.m ├── end_fed_Horizontal.m ├── figs │ ├── 3D_center_fed.jpg │ └── travelin_wave.jpg └── short_dipole_Vertical.m ├── figs └── Radiation_pattern.jpg └── fourier ├── README.md ├── examples ├── README.md ├── fourier1.m ├── fourier2.m ├── fourier3.m └── fourier4.m ├── figs ├── 13_element.jpg └── 7_element.jpg └── fourier.m /README.md: -------------------------------------------------------------------------------- 1 | # Antenna_pattern_and_design 2 | 1. Compute the **radiation patterns** of several [dipole antennas](dipole/). 3 | 2. Compute the **radiation patterns** of diverse types of [linear antenna-arrays](broadside_endfire/). 4 | 3. **Design diverse types of linear antenna-arrays** using [Fourier series](fourier/) and [Chebyshev polynomials](chebyshev/). 5 | 6 | **Example**: comparison of radiation patterns from 4 different end-fire arrays (see the code that generates this figure [here](broadside_endfire/null_spacing_Comparison.m)) 7 | ![example1](figs/Radiation_pattern.jpg) 8 | -------------------------------------------------------------------------------- /broadside_endfire/Comparison.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | prompt = sprintf ('What is the number of elements in the array? \n'); 10 | n = input(prompt); 11 | if ~isscalar(n) || (n~=floor(n)) || n<=1 12 | error('Introduce an integer scalar bigger than 1 for the number of elements in the array') 13 | end 14 | 15 | prompt = sprintf ('Broadside or end-fire array? \n(answer "broadside" or "end_fire", as a string in MATLAB) \n'); 16 | array_type = input(prompt); 17 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') 18 | error('Wrong type of array introduced.') 19 | end 20 | 21 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 22 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 23 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 24 | % - If I am given the value of alpha and it is different than 0, it means 25 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 26 | d = input(prompt); 27 | if ~isscalar(d) 28 | error('Introduce a scalar for the value of "d"') 29 | end 30 | if d~=1/2 31 | disp('The binomial array is not going to be plotted, as "d" has to be 1/2*lambda for this type of array') 32 | end 33 | 34 | kd = 2*pi*d; 35 | 36 | if strcmp(array_type,'broadside') 37 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 38 | elseif strcmp(array_type,'end_fire') 39 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 40 | end 41 | 42 | %% Uniform 43 | % Calculate the radiation pattern as a function of phi: 44 | i=1; 45 | phi = []; 46 | ET_over_E0 = []; 47 | if strcmp(array_type,'broadside') 48 | % I checked by testing the expression for phi as a function of psi, and this is what I need to print the 360° of phi 49 | psi_initial = -kd; 50 | psi_end = kd; 51 | elseif strcmp(array_type,'end_fire') 52 | psi_initial = -2*kd; 53 | psi_end = 0; 54 | end 55 | psi_step = (psi_end-psi_initial)/1000; 56 | for psi=psi_initial:psi_step:psi_end 57 | phi(i) = abs(acos((psi-alpha)/kd)); 58 | if ((psi>-1e-5)&&(psi<1e-5)) || ((psi>-2*pi-1e-5)&&(psi<-2*pi+1e-5)) 59 | ET_over_E0(i) = n; % Solved by L'Hopitals rule 60 | else 61 | ET_over_E0(i) = abs(sin(n*psi/2)/sin(psi/2)); 62 | end 63 | i=i+1; 64 | end 65 | ET_over_E0 = ET_over_E0/max(ET_over_E0); % Normalize 66 | 67 | 68 | phi = phi*360/(2*pi); % Convert to degree 69 | 70 | figure(1) 71 | plot(phi,ET_over_E0,'Color',[0 0.4470 0.7410]) 72 | % Color code: 73 | % 0 0.4470 0.7410 74 | % 0.8500 0.3250 0.0980 75 | % 0.9290 0.6940 0.1250 76 | % 0.4940 0.1840 0.5560 77 | % 0.4660 0.6740 0.1880 78 | % 0.3010 0.7450 0.9330 79 | % 0.6350 0.0780 0.1840 80 | %axis([0 180 0 1]) 81 | xlabel('\phi','fontsize',15) 82 | ylabel('E','fontsize',12) 83 | title([num2str(n) '-elements array']) 84 | hold on 85 | 86 | clear i psi ET_over_E0 87 | 88 | %% Triangular 89 | n = (n+1)/2; % Because the "n" that I use in the expression for the triangular array is not actually its length, it is the length of the uniform array that it comes from (see my class notes back of page 20, the length of the triangular array is 2*n-1, being "n" the length of a uniform array that the triangular array is derived from) 90 | phi = 0:0.001:pi; 91 | % psi = kd*cos(phi)+alpha; 92 | % z = exp(j*psi); 93 | z = exp(j*(kd*cos(phi)+alpha)); 94 | E = 0; % Initialize 95 | for array_position=1:n 96 | E = E + array_position*z.^(array_position-1); 97 | end 98 | substract = 0; % Initialize. This is used to get the decreasing part of the triangle coefficients 99 | for array_position=(n+1):(2*n-1) 100 | E = E + (n-1-substract)*z.^(array_position-1); 101 | substract = substract+1; 102 | end 103 | E = abs(E); 104 | E = E/max(E); % Normalize 105 | 106 | phi = phi*360/(2*pi); 107 | 108 | figure(1) 109 | plot(phi,E,'Color',[0.8500 0.3250 0.0980]) 110 | hold on 111 | 112 | %% Binomial 113 | if d==1/2 114 | % Calculate the basic pattern, the "8" that we get when considering just 115 | % 2 antennae in the array: 116 | n_basic = 2; 117 | 118 | % Calculate the radiation pattern as a function of phi: 119 | i=1; 120 | phi = []; 121 | ET_over_E0 = []; 122 | if strcmp(array_type,'broadside') 123 | % I checked by testing the expression for phi as a function of psi, and this is what I need to print the 360° of phi 124 | psi_initial = -kd; 125 | psi_end = kd; 126 | elseif strcmp(array_type,'end_fire') 127 | psi_initial = -2*kd; 128 | psi_end = 0; 129 | end 130 | psi_step = (psi_end-psi_initial)/1000; 131 | for psi=psi_initial:psi_step:psi_end 132 | phi(i) = abs(acos((psi-alpha)/kd)); 133 | if ((psi>-1e-5)&&(psi<1e-5)) || ((psi>-2*pi-1e-5)&&(psi<-2*pi+1e-5)) 134 | ET_over_E0(i) = n_basic; % Solved by L'Hopitals rule 135 | else 136 | ET_over_E0(i) = abs(sin(n_basic*psi/2)/sin(psi/2)); 137 | end 138 | i=i+1; 139 | end 140 | 141 | % Multiplication by the number of elements in the array, "n": 142 | ET_over_E0 = ET_over_E0.^(n-1); 143 | 144 | ET_over_E0 = ET_over_E0/max(ET_over_E0); % Normalize 145 | 146 | phi = phi*360/(2*pi); 147 | 148 | figure(1) 149 | plot(phi,ET_over_E0,'Color',[0.9290 0.6940 0.1250]) 150 | legend('Uniform','Triangular','Binomial') 151 | end 152 | 153 | grid on 154 | 155 | -------------------------------------------------------------------------------- /broadside_endfire/README.md: -------------------------------------------------------------------------------- 1 | Compute radiation patterns for different types of **broadside** and **end-fire** antenna-arrays. 2 | 3 | Types of arrays, depending on their current distribution: 4 | - [Uniform array](uniform.m/): currents are the same in all elements of the array. Gives secondary lobes whenever the elements are more than half-wavelength apart. 5 | - [Binomial array](binomial.m/): currents follow a binomial distribution. Gives no secondary lobes, only a wide primary lobe. 6 | - [Triangular array](triangular.m/): current ratios are triangular. Gives narrower main lobes than binomial, but with some secondary lobes (althought he secondary lobes are smaller than in the uniform array). 7 | 8 | [This file](Comparison.m/) compares all 3 current distributions mentioned above. 9 | 10 | It is possible to move the null points in the radiation pattern, see [this file](null_spacing.m/). 11 | 12 | Finally [this file](null_spacing_Comparison.m/) makes a comprehensive comparison of any type of array mentioned above. 13 | -------------------------------------------------------------------------------- /broadside_endfire/binomial.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | prompt = sprintf ('What is the number of elements in the array? \n'); 10 | n = input(prompt); 11 | if ~isscalar(n) || (n~=floor(n)) || n<=1 12 | error('Introduce an integer scalar bigger than 1 for the number of elements in the array') 13 | end 14 | 15 | prompt = sprintf ('Broadside or end-fire array? \n(answer "broadside" or "end_fire", as a string in MATLAB) \n'); 16 | array_type = input(prompt); 17 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') 18 | error('Wrong type of array introduced.') 19 | end 20 | 21 | d = 1/2; % This means d = lambda/2. For binomial, d must be d<=1/2 22 | kd = pi; % Because kd = 2*pi/lambda*d, and d=lambda/2 for the binomial arrays, so kd = pi 23 | 24 | if strcmp(array_type,'broadside') 25 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 26 | elseif strcmp(array_type,'end_fire') 27 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 28 | end 29 | 30 | % Now calculate the basic pattern, the "8" that we get when considering just 31 | % 2 antennae in the array: 32 | n_basic = 2; 33 | 34 | %% 35 | % Now calculate the radiation pattern as a function of psi: 36 | i=1; 37 | psi = 0:0.001:pi; 38 | ET_over_E0 = []; 39 | for k=1:length(psi) 40 | if i==1 41 | ET_over_E0(i) = n_basic; % Solved by L'Hopitals rule 42 | else 43 | ET_over_E0(i) = abs(sin(n_basic*psi(k)/2)/sin(psi(k)/2)); 44 | end 45 | i=i+1; 46 | end 47 | 48 | % Multiplication by the number of elements in the array, "n": 49 | ET_over_E0 = ET_over_E0.^(n-1); 50 | 51 | % Now get the rest of the values for psi, since the radiation pattern as a 52 | % function of psi is symmetrical with respect to the psi=pi axis: 53 | psi(i:2*(i-1)) = psi(1:end)+pi; 54 | ET_over_E0(i:2*(i-1)) = fliplr(ET_over_E0); 55 | 56 | psi = psi*360/(2*pi); 57 | 58 | figure(1) 59 | plot(psi,ET_over_E0) 60 | axis([0 360 0 n_basic.^(n-1)]) 61 | xlabel('\psi','fontsize',15) 62 | ylabel('E_T/E_o','fontsize',12) 63 | title(['n=' num2str(n)]) 64 | 65 | clear i psi ET_over_E0 66 | 67 | %% 68 | % Now calculate the radiation pattern as a function of phi: 69 | i=1; 70 | phi = []; 71 | ET_over_E0 = []; 72 | if strcmp(array_type,'broadside') 73 | % I checked by testing the expression for phi as a function of psi, and this is what I need to print the 360° of phi 74 | psi_initial = -kd; 75 | psi_end = kd; 76 | elseif strcmp(array_type,'end_fire') 77 | psi_initial = -2*kd; 78 | psi_end = 0; 79 | end 80 | psi_step = (psi_end-psi_initial)/1000; 81 | for psi=psi_initial:psi_step:psi_end 82 | phi(i) = abs(acos((psi-alpha)/kd)); 83 | if ((psi>-1e-5)&&(psi<1e-5)) || ((psi>-2*pi-1e-5)&&(psi<-2*pi+1e-5)) 84 | ET_over_E0(i) = n_basic; % Solved by L'Hopitals rule 85 | else 86 | ET_over_E0(i) = abs(sin(n_basic*psi/2)/sin(psi/2)); 87 | end 88 | i=i+1; 89 | end 90 | 91 | % Multiplication by the number of elements in the array, "n": 92 | ET_over_E0 = ET_over_E0.^(n-1); 93 | 94 | % Now get the rest of the values for phi, since the radiation pattern as a 95 | % function of phi is symmetrical with respect to the phi=0 axis: 96 | phi(i:2*(i-1)) = -fliplr(phi); 97 | ET_over_E0(i:2*(i-1)) = fliplr(ET_over_E0); 98 | 99 | figure(2) 100 | polar(phi,ET_over_E0) 101 | title('E_T/E_o as a function of \phi') 102 | 103 | % Calculate width of the primary maxima (Units: radian): 104 | if strcmp(array_type,'broadside') 105 | width_PM = 2/(n*d) % I don't include "lambda" in this formula because "d" has been specified in terms of "times of lambda", so it cancels out lambda 106 | disp('Units: radians') 107 | disp('NOTE: this used the formula for uniform distribution, I guess it is also valid for binomial') 108 | elseif strcmp(array_type,'end_fire') 109 | width_PM = 2*sqrt(2/(n*d)) % I don't include "lambda" in this formula because "d" has been specified in terms of "times of lambda", so it cancels out lambda 110 | disp('Units: radians') 111 | disp('NOTE: this used the formula for uniform distribution, I guess it is also valid for binomial') 112 | end 113 | -------------------------------------------------------------------------------- /broadside_endfire/null_spacing.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | prompt = sprintf ('What is the number of elements in the array? \n'); 10 | n = input(prompt); 11 | if ~isscalar(n) || (n~=floor(n)) || n<=1 12 | error('Introduce an integer scalar bigger than 1 for the number of elements in the array') 13 | end 14 | 15 | prompt = sprintf ('Broadside or end-fire array? \n(answer "broadside" or "end_fire", as a string in MATLAB) \n'); 16 | array_type = input(prompt); 17 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') 18 | error('Wrong type of array introduced.') 19 | end 20 | 21 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 22 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 23 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 24 | % - If I am given the value of alpha and it is different than 0, it means 25 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 26 | d = input(prompt); 27 | if ~isscalar(d) 28 | error('Introduce a scalar for the value of "d"') 29 | end 30 | if d>=1/2 31 | error('"d" has to be smaller than 1/2*lambda for nulls to be able to be re-spaced') 32 | end 33 | 34 | kd = 2*pi*d; 35 | 36 | if strcmp(array_type,'broadside') 37 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 38 | elseif strcmp(array_type,'end_fire') 39 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 40 | end 41 | 42 | %% 43 | % Calculate the range of psi: 44 | disp('Range of psi:') 45 | psi_max = kd+alpha % Using phi=0° 46 | psi_min = -kd+alpha % Using phi=180° 47 | 48 | % Number of nulls: 49 | nulls_number = n-1; 50 | 51 | for m=1:n-1 52 | null(m) = m*(2*pi/n); 53 | end 54 | figure(1) 55 | polar(null,ones(1,length(null)),'o') 56 | title('Original nulls') 57 | 58 | for i=1:nulls_number 59 | new_nulls(i) = i*(psi_max-psi_min)/nulls_number; 60 | end 61 | if strcmp(array_type,'broadside') 62 | new_nulls = new_nulls-kd-(psi_max-psi_min)/nulls_number; 63 | elseif strcmp(array_type,'end_fire') 64 | new_nulls = new_nulls+(2*pi-2*kd)-(psi_max-psi_min)/nulls_number; 65 | end 66 | figure(2) 67 | polar(new_nulls,ones(1,length(null)),'o') 68 | title('New nulls') 69 | 70 | %% 71 | % Draw the radiation pattern as a function of phi: 72 | phi = 0:0.001:pi; 73 | %psi = 0:0.0001:pi; 74 | %psi = kd*cos(phi)+alpha; 75 | %z = exp(j*psi); 76 | z = exp(j*(kd*cos(phi)+alpha)); 77 | E = 1; % Initialize 78 | for i=1:nulls_number 79 | E = E.*(z-exp(j*new_nulls(i))); 80 | end 81 | E = abs(E); 82 | E = E/max(E); % Normalize 83 | phi = phi*360/(2*pi); 84 | 85 | figure(1) 86 | plot(phi,E) 87 | %axis([0 pi 0 n]) 88 | xlabel('\phi','fontsize',15) 89 | ylabel('E_T/E_o','fontsize',12) 90 | title(['n=' num2str(n)]) 91 | -------------------------------------------------------------------------------- /broadside_endfire/null_spacing_Comparison.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | prompt = sprintf ('How many arrays are to be compared? \n'); 10 | number_arrays = input(prompt); 11 | if ~isscalar(number_arrays) || (number_arrays~=floor(number_arrays)) || number_arrays<=1 || number_arrays>5 12 | error('Introduce an integer scalar bigger than 1 and smaller than 6 for the number of arrays to be compared') 13 | end 14 | 15 | prompt = sprintf ('Broadside or end-fire arrays? \n(answer "broadside" or "end_fire", as a string in MATLAB) \n'); 16 | array_type = input(prompt); 17 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') 18 | error('Wrong type of array introduced.') 19 | end 20 | 21 | string_array{1} = '1st'; 22 | string_array{2} = '2nd'; 23 | string_array{3} = '3rd'; 24 | string_array{4} = '4th'; 25 | string_array{5} = '5th'; 26 | 27 | for i=1:number_arrays 28 | prompt = sprintf (['What is the number of elements in the ' string_array{i} ' array? \n']); 29 | n(i) = input(prompt); 30 | if ~isscalar(n(i)) || (n(i)~=floor(n(i))) || n(i)<=1 31 | error('Introduce an integer scalar bigger than 1 for the number of elements in the array') 32 | end 33 | end 34 | 35 | for i=1:number_arrays 36 | prompt = sprintf (['What is the value of "d", separation between \neach antenna and the following one in the ' string_array{i} ' array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n']); 37 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 38 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 39 | % - If I am given the value of alpha and it is different than 0, it means 40 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 41 | d(i) = input(prompt); 42 | if ~isscalar(d(i)) 43 | error('Introduce a scalar for the value of "d"') 44 | end 45 | if d(i)>=1/2 46 | disp('NOTE: "d" has to be smaller than 1/2*lambda for nulls to be able to be re-spaced') 47 | end 48 | 49 | kd(i) = 2*pi*d(i); 50 | 51 | if strcmp(array_type,'broadside') 52 | alpha(i) = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 53 | elseif strcmp(array_type,'end_fire') 54 | alpha(i) = -kd(i); % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 55 | end 56 | end 57 | 58 | prompt = sprintf ('Do you want any of these arrays to have uniform current distribution? \n(answer with the number of the array you want to be uniform, \n or 0 if you dont want any array to be uniform) \n'); 59 | nulls_respacing = input(prompt); 60 | if ~isscalar(nulls_respacing) || (nulls_respacing~=floor(nulls_respacing)) || nulls_respacing<0 || nulls_respacing>number_arrays 61 | error('Insert an integer bigger than 0 and lower than the number of arrays considered') 62 | end 63 | no_respacing(number_arrays) = 0; 64 | if nulls_respacing>0 65 | no_respacing(nulls_respacing) = 1; 66 | end 67 | 68 | %% Patterns 69 | p = 2; % Initialize index 70 | for i=1:number_arrays 71 | if d(i)>=1/2 || no_respacing(i)==1 % No null re-spacing possible in this case, or not wanted by the user 72 | % Number of nulls: 73 | nulls_number(i) = n(i)-1; 74 | 75 | for m=1:n(i)-1 76 | null{i}{m} = m*(2*pi/n(i)); 77 | end 78 | null = cell2mat(null{i}); 79 | 80 | % Draw the radiation pattern as a function of phi: 81 | phi = 0:0.001:pi; 82 | %psi = 0:0.0001:pi; 83 | %psi = kd*cos(phi)+alpha; 84 | %z = exp(j*psi); 85 | z = exp(j*(kd(i)*cos(phi)+alpha(i))); 86 | E = 1; % Initialize 87 | for q=1:nulls_number(i) 88 | E = E.*(z-exp(j*null(q))); 89 | end 90 | E = abs(E); 91 | E = E/max(E); % Normalize 92 | phi = phi*360/(2*pi); 93 | 94 | figure(1) 95 | plot(phi,E,'LineWidth',2) 96 | %axis([0 pi 0 n]) 97 | xlabel('\phi','fontsize',18) 98 | ylabel('|E|','fontsize',15) 99 | hold on 100 | 101 | if d(i)>=1/2 102 | string_legend{i} = [num2str(n(i)) '-element array, d=\lambda/' num2str(1/d(i)) ' (no null re-spacing possible)']; 103 | else 104 | string_legend{i} = [num2str(n(i)) '-element array, d=\lambda/' num2str(1/d(i)) ', uniform']; 105 | end 106 | 107 | clear null 108 | 109 | else % In this case, there is going to be null re-spacing 110 | %% 111 | % Calculate the range of psi: 112 | disp(['Range of psi for the ' string_array{i} ' array:']) 113 | psi_max(i) = kd(i)+alpha(i); % Using phi=0° 114 | psi_min(i) = -kd(i)+alpha(i); % Using phi=180° 115 | psi_max(i) 116 | psi_min(i) 117 | 118 | % Number of nulls: 119 | nulls_number(i) = n(i)-1; 120 | 121 | for m=1:n(i)-1 122 | null{i}{m} = m*(2*pi/n(i)); 123 | end 124 | 125 | figure(p) 126 | polar(cell2mat(null{i}),ones(1,length(cell2mat(null{i}))),'o') 127 | hold on 128 | title([string_array{i} ' array - Original nulls']) 129 | 130 | for l=1:nulls_number(i) 131 | new_nulls{i}{l} = l*(psi_max(i)-psi_min(i))/nulls_number(i); 132 | end 133 | if strcmp(array_type,'broadside') 134 | new_nulls = cell2mat(new_nulls{i}); 135 | new_nulls = new_nulls-kd(i)-(psi_max(i)-psi_min(i))/nulls_number(i); 136 | elseif strcmp(array_type,'end_fire') 137 | new_nulls = cell2mat(new_nulls{i}); 138 | new_nulls = new_nulls+(2*pi-2*kd(i))-(psi_max(i)-psi_min(i))/nulls_number(i); 139 | end 140 | p = p+1; 141 | figure(p) 142 | polar(new_nulls,ones(1,length(new_nulls)),'o') 143 | hold on 144 | title([string_array{i} ' array - New nulls']) 145 | p = p+1; 146 | 147 | %% 148 | % Draw the radiation pattern as a function of phi: 149 | phi = 0:0.001:pi; 150 | %psi = 0:0.0001:pi; 151 | %psi = kd*cos(phi)+alpha; 152 | %z = exp(j*psi); 153 | z = exp(j*(kd(i)*cos(phi)+alpha(i))); 154 | E = 1; % Initialize 155 | for q=1:nulls_number(i) 156 | E = E.*(z-exp(j*new_nulls(q))); 157 | end 158 | E = abs(E); 159 | E = E/max(E); % Normalize 160 | phi = phi*360/(2*pi); 161 | 162 | figure(1) 163 | plot(phi,E,'LineWidth',2) 164 | %axis([0 pi 0 n]) 165 | xlabel('\phi','fontsize',18) 166 | ylabel('|E|','fontsize',15) 167 | hold on 168 | string_legend{i} = [num2str(n(i)) '-element array, d=\lambda/' num2str(1/d(i)) ', nulls re-spaced']; 169 | 170 | clear new_nulls 171 | end 172 | end 173 | 174 | figure(1) 175 | set(gca,'fontsize',15) 176 | legend(string_legend,'Location','NorthOutside') 177 | grid on 178 | print(figure(1),'-dtiff', 'Radiation_pattern') 179 | -------------------------------------------------------------------------------- /broadside_endfire/triangular.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | prompt = sprintf ('What is the number of elements in the array? \n'); 10 | n = input(prompt); 11 | if ~isscalar(n) || (n~=floor(n)) || n<=1 12 | error('Introduce an integer scalar bigger than 1 for the number of elements in the array') 13 | end 14 | 15 | prompt = sprintf ('Broadside or end-fire array? \n(answer "broadside" or "end_fire", as a string in MATLAB) \n'); 16 | array_type = input(prompt); 17 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') 18 | error('Wrong type of array introduced.') 19 | end 20 | 21 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 22 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 23 | % If I am given the value of kd, calculate d as d=kd/2*pi. 24 | % If I am given the value of alpha and it is different than 0, it means 25 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 26 | d = input(prompt); 27 | if ~isscalar(d) 28 | error('Introduce a scalar for the value of "d"') 29 | end 30 | 31 | kd = 2*pi*d; 32 | 33 | if strcmp(array_type,'broadside') 34 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 35 | elseif strcmp(array_type,'end_fire') 36 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 37 | end 38 | 39 | %% 40 | % Now calculate the radiation pattern as a function of phi: 41 | n = (n+1)/2; % Because the "n" that I use in the expression for the triangular array is not actually its length, it is the length of the uniform array that it comes from (see my class notes back of page 20, the length of the triangular array is 2*n-1, being "n" the length of a uniform array that the triangular array is derived from) 42 | phi = 0:0.001:pi; 43 | %psi = 0:0.0001:pi; 44 | %psi = kd*cos(phi)+alpha; 45 | %z = exp(j*psi); 46 | z = exp(j*(kd*cos(phi)+alpha)); 47 | E = 0; % Initialize 48 | for array_position=1:n 49 | E = E + array_position*z.^(array_position-1); 50 | end 51 | substract = 0; % Initialize. This is used to get the decreasing part of the triangle coefficients 52 | for array_position=(n+1):(2*n-1) 53 | E = E + (n-1-substract)*z.^(array_position-1); 54 | substract = substract+1; 55 | end 56 | 57 | E = abs(E); 58 | 59 | figure(1) 60 | plot(phi,E) 61 | %axis([0 pi 0 n]) 62 | xlabel('\phi','fontsize',15) 63 | ylabel('E_T/E_o','fontsize',12) 64 | title(['n=' num2str(2*n-1)]) 65 | 66 | % Now let's draw the polar plot: 67 | % Now get the rest of the values for phi, since the radiation pattern as a 68 | % function of phi is symmetrical with respect to the phi=0 axis: 69 | l = length(phi); 70 | phi(l+1:2*l) = -fliplr(phi); 71 | E(l+1:2*l) = fliplr(E); 72 | 73 | figure(2) 74 | polar(phi,E) 75 | title('E as a function of \phi') 76 | 77 | clear i psi ET_over_E0 78 | 79 | %% 80 | % Calculate width of the primary maxima (Units: radians): 81 | if strcmp(array_type,'broadside') 82 | width_PM = 2/(n*d) % I don't include "lambda" in this formula because "d" has been specified in terms of "times of lambda", so it cancels out lambda 83 | disp('Units: radians') 84 | disp('NOTE: this used the formula for uniform distribution, I guess it is also valid for triangular') 85 | elseif strcmp(array_type,'end_fire') 86 | width_PM = 2*sqrt(2/(n*d)) % I don't include "lambda" in this formula because "d" has been specified in terms of "times of lambda", so it cancels out lambda 87 | disp('Units: radians') 88 | disp('NOTE: this used the formula for uniform distribution, I guess it is also valid for triangular') 89 | end 90 | -------------------------------------------------------------------------------- /broadside_endfire/uniform.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | prompt = sprintf ('What is the number of elements in the array? \n'); 10 | n = input(prompt); 11 | if ~isscalar(n) || (n~=floor(n)) || n<=1 12 | error('Introduce an integer scalar bigger than 1 for the number of elements in the array') 13 | end 14 | 15 | prompt = sprintf ('Broadside or end-fire array? \n(answer "broadside" or "end_fire", as a string in MATLAB) \n'); 16 | array_type = input(prompt); 17 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') 18 | error('Wrong type of array introduced.') 19 | end 20 | 21 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 22 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 23 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 24 | % - If I am given the value of alpha and it is different than 0, it means 25 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 26 | d = input(prompt); 27 | if ~isscalar(d) 28 | error('Introduce a scalar for the value of "d"') 29 | end 30 | 31 | kd = 2*pi*d; 32 | 33 | if strcmp(array_type,'broadside') 34 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 35 | elseif strcmp(array_type,'end_fire') 36 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 37 | end 38 | 39 | %% 40 | % Now calculate the radiation pattern as a function of psi: 41 | i=1; 42 | psi = 0:0.001:pi; 43 | ET_over_E0 = []; 44 | for k=1:length(psi) 45 | if i==1 46 | ET_over_E0(i) = n; % Solved by L'Hopitals rule 47 | else 48 | ET_over_E0(i) = abs(sin(n*psi(k)/2)/sin(psi(k)/2)); 49 | end 50 | i=i+1; 51 | end 52 | % Now get the rest of the values for psi, since the radiation pattern as a 53 | % function of psi is symmetrical with respect to the psi=pi axis: 54 | psi(i:2*(i-1)) = psi(1:end)+pi; 55 | ET_over_E0(i:2*(i-1)) = fliplr(ET_over_E0); 56 | 57 | figure(1) 58 | plot(psi,ET_over_E0) 59 | axis([0 2*pi 0 n]) 60 | xlabel('\psi','fontsize',15) 61 | ylabel('E_T/E_o','fontsize',12) 62 | title(['n=' num2str(n)]) 63 | 64 | clear i psi ET_over_E0 65 | 66 | %% 67 | % Now calculate the radiation pattern as a function of phi: 68 | i=1; 69 | phi = []; 70 | ET_over_E0 = []; 71 | if strcmp(array_type,'broadside') 72 | % I checked by testing the expression for phi as a function of psi, and this is what I need to print the 360° of phi 73 | psi_initial = -kd; 74 | psi_end = kd; 75 | elseif strcmp(array_type,'end_fire') 76 | psi_initial = -2*kd; 77 | psi_end = 0; 78 | end 79 | psi_step = (psi_end-psi_initial)/1000; 80 | for psi=psi_initial:psi_step:psi_end 81 | phi(i) = abs(acos((psi-alpha)/kd)); 82 | if ((psi>-1e-5)&&(psi<1e-5)) || ((psi>2*pi-1e-5)&&(psi<2*pi+1e-5)) 83 | ET_over_E0(i) = n; % Solved by L'Hopitals rule 84 | else 85 | ET_over_E0(i) = abs(sin(n*psi/2)/sin(psi/2)); 86 | end 87 | i=i+1; 88 | end 89 | 90 | % Now get the rest of the values for phi, since the radiation pattern as a 91 | % function of phi is symmetrical with respect to the phi=0 axis: 92 | phi(i:2*(i-1)) = -fliplr(phi); 93 | ET_over_E0(i:2*(i-1)) = fliplr(ET_over_E0); 94 | 95 | figure(2) 96 | polar(phi,ET_over_E0) 97 | title('E_T/E_o as a function of \phi') 98 | 99 | %% 100 | % Calculate width of the primary maxima (Units: radians): 101 | if strcmp(array_type,'broadside') 102 | width_PM = 2/(n*d) % I don't include "lambda" in this formula because "d" has been specified in terms of "times of lambda", so it cancels out lambda 103 | disp('Units: radians') 104 | elseif strcmp(array_type,'end_fire') 105 | width_PM = 2*sqrt(2/(n*d)) % I don't include "lambda" in this formula because "d" has been specified in terms of "times of lambda", so it cancels out lambda 106 | disp('Units: radians') 107 | end 108 | 109 | %% THIS PART IS NOT NECESSARY NOW, and actually it doesn't work as the code is now 110 | % % For conversion from psi pattern to phi pattern one also can do this: 111 | % % psi = kd*cos(phi)+alpha, therefore 112 | % % phi = acos((psi-alpha)/kd), but the "acos" function is only defined for 113 | % % values of its argument between -1 and 1, then the values of psi have to 114 | % % be within these limits: 115 | % psi_max = 2*pi*d+alpha 116 | % psi_min = -2*pi*d+alpha 117 | % 118 | % psi_limits = (psi<=psi_max).*(psi>=psi_min); 119 | % psi_valid = psi.*psi_limits; 120 | % 121 | % phi = acos((psi-alpha)/kd) 122 | -------------------------------------------------------------------------------- /chebyshev/README.md: -------------------------------------------------------------------------------- 1 | For a given antenna array (which you can design to follow a prescribed radiation pattern [using a truncated Fourier series](../fourier)), you can determine the current distributions that will result in the **narrowest main lobe for a specified side lode level**. This can be done using a **Chebyshev** distribution as in this code. 2 | 3 | Example of a 6-element broadside array, with element spacing of half-wavelength and a side-lobe level down 20dB: 4 | ![Example](figs/6_element_Cheby_2.jpg) 5 | -------------------------------------------------------------------------------- /chebyshev/chebysheff.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | prompt = sprintf ('What is the number of elements in the array? \n'); 10 | n = input(prompt); 11 | if ~isscalar(n) || (n~=floor(n)) || n<=1 12 | error('Introduce an integer scalar bigger than 1 for the number of elements in the array') 13 | end 14 | 15 | prompt = sprintf ('Broadside or end-fire array? \n(answer "broadside" or "end_fire", as a string in MATLAB) \n'); 16 | array_type = input(prompt); 17 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') 18 | error('Wrong type of array introduced.') 19 | end 20 | 21 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 22 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 23 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 24 | % - If I am given the value of alpha and it is different than 0, it means 25 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 26 | d = input(prompt); 27 | if ~isscalar(d) 28 | error('Introduce a scalar for the value of "d"') 29 | end 30 | 31 | prompt = sprintf ('What is the desired value of the side lobes \nto main lobe attenuation, in dB? \n(introducing "20" means the side lobes is 20dB below the main lobe) \n'); 32 | dB_sideLobe = input(prompt); 33 | if ~isscalar(dB_sideLobe) || dB_sideLobe<=0 34 | error('Introduce a positive scalar') 35 | end 36 | 37 | kd = 2*pi*d; 38 | 39 | if strcmp(array_type,'broadside') 40 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 41 | elseif strcmp(array_type,'end_fire') 42 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 43 | end 44 | 45 | %% 46 | Cheby_order = n-1; % The order of the Chebyshev polynomial is one less than the # of elements in the array 47 | % This is valid for up to 40dB, if more attenuation is needed, take more 48 | % points in "x": 49 | if Cheby_order==1 50 | x = -100:0.01:100; 51 | elseif Cheby_order==2 52 | x = -10:0.001:10; 53 | else 54 | x = -3.5:0.001:3.5; 55 | end 56 | y = chebyshevT(Cheby_order,x); 57 | figure(1) 58 | plot(x,y) 59 | grid on 60 | 61 | % Calculate the value of b (see last pages of my notes): 62 | b = 10^(dB_sideLobe/20); 63 | 64 | index_zero = find(y>b-1e-2); 65 | x_o = x(index_zero(1)); 66 | 67 | for k=1:Cheby_order 68 | delta_k_o(k) = (2*k-1)*pi/(2*Cheby_order); 69 | x_k_o(k) = cos(delta_k_o(k)); 70 | psi_k_o(k) =2*acos(x_k_o(k)/x_o); 71 | end 72 | 73 | phi = 0:0.001:pi; 74 | %psi = 0:0.0001:pi; 75 | %psi = kd*cos(phi)+alpha; 76 | %z = exp(j*psi); 77 | z = exp(j*(kd*cos(phi)+alpha)); 78 | E = 1; % Initialize 79 | for l=1:Cheby_order 80 | E = E.*(z-exp(j*psi_k_o(l))); 81 | end 82 | E = abs(E); 83 | E = E/max(E); % Normalize 84 | phi = phi*360/(2*pi); 85 | 86 | figure(1) 87 | plot(phi,E) 88 | %axis([0 pi 0 n]) 89 | xlabel('\phi','fontsize',15) 90 | ylabel('|E|','fontsize',12) 91 | grid on 92 | title([num2str(n) '-element array, Tchebysheff distribution']) 93 | 94 | -------------------------------------------------------------------------------- /chebyshev/figs/6_element_Cheby_2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badber/Antenna_pattern_and_design/be98cfa14192e6f031d3732d63270fbba8094733/chebyshev/figs/6_element_Cheby_2.jpg -------------------------------------------------------------------------------- /dipole/README.md: -------------------------------------------------------------------------------- 1 | Compute radiation patterns of **dipole antennas**. 2 | 3 | (note: end-fed dipoles are also called *traveling-wave antennas*) 4 | 5 | **Example**: center-fed dipole, 5/2-wavelengths long (3D radiation pattern) 6 | ![example1](figs/3D_center_fed.jpg) 7 | 8 | **Example 2**: traveling-wave antenna, 7-wavelengths long 9 | ![example2](figs/travelin_wave.jpg) 10 | -------------------------------------------------------------------------------- /dipole/center_fed_Vertical.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% Vertical Dipole antenna (center-fed) 4 | clear all 5 | close all 6 | clc 7 | 8 | prompt = sprintf ('What is the length of the dipole antenna, in terms of lambda? \nL = x means here that L = x*lambda \n'); 9 | L = input(prompt); % "L = x" means here that "L = x*lambda" 10 | if ~isscalar(L) || L<0 11 | error('Introduce a scalar bigger than 0 for the length of the dipole antenna') 12 | end 13 | 14 | % Modify these next 2 parameters for each case: 15 | Im = 2; 16 | r = 2; 17 | 18 | % Dipole antenna equations: 19 | theta = 0:0.01:2*pi; 20 | E_theta = abs(60*Im/r*((cos(2*pi*L/2*cos(theta))-cos(2*pi*L/2))./sin(theta))); 21 | 22 | figure(1) 23 | polar(theta-pi/2,E_theta) % I substract pi/2 from theta so that the pattern corresponds to a vertical antenna instead of a horizontal one 24 | title('E_{\theta}') 25 | 26 | % 3D plot: 27 | 28 | [theta,phi] = meshgrid(0:0.01:pi,0:0.01:2*pi); 29 | E_theta = 60*Im/r*((cos(2*pi*L/2*cos(theta))-cos(2*pi*L/2))./sin(theta)); 30 | 31 | % Transforming to XYZ (cartersian) 32 | x = E_theta.*sin(theta).*cos(phi); 33 | y = E_theta.*sin(theta).*sin(phi); 34 | z = E_theta.*cos(theta); 35 | 36 | % For cutting with 2 semi-planes: 37 | a = x<0; 38 | b = y<0; 39 | c = a.*b; 40 | 41 | for j=1:size(c,1) 42 | for k=1:size(c,2) 43 | if c(j,k)>0 44 | c(j,k) = NaN; 45 | end 46 | end 47 | end 48 | 49 | z_noPlot = z.*c; 50 | z = z + z_noPlot; 51 | 52 | figure(2) 53 | mesh(x,y,z); 54 | -------------------------------------------------------------------------------- /dipole/end_fed_Horizontal.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% Horizontal Dipole antenna (end-fed) 4 | clear all 5 | close all 6 | clc 7 | 8 | prompt = sprintf ('What is the length of the dipole antenna, in terms of lambda? \nL = x means here that L = x*lambda \n'); 9 | L = input(prompt); % "L = x" means here that "L = x*lambda" 10 | if ~isscalar(L) || L<0 11 | error('Introduce a scalar bigger than 0 for the length of the dipole antenna') 12 | end 13 | 14 | % Modify these next 2 parameters for each case: 15 | Im = 2; 16 | r = 2; 17 | 18 | % Dipole antenna equations: 19 | theta = 0:0.01:2*pi; 20 | u = 2*pi*L/2*(cos(theta)-1); 21 | E_theta = abs(30*Im*sin(theta)*L.*sin(u)./u); % This formula is taken from page 5 of "traveling_wave.pdf" 22 | 23 | figure(1) 24 | polar(theta,E_theta) 25 | 26 | % 3D plot: 27 | 28 | [theta,phi] = meshgrid(0:0.01:pi,0:0.01:2*pi); 29 | u = 2*pi*L/2*(cos(theta)-1); 30 | E_theta = abs(30*Im*sin(theta)*L.*sin(u)./u); 31 | 32 | % Transforming to XYZ (cartersian) 33 | x = E_theta.*sin(theta).*cos(phi); 34 | y = E_theta.*sin(theta).*sin(phi); 35 | z = E_theta.*cos(theta); 36 | 37 | % For cutting with 2 semi-planes: 38 | a = x<0; 39 | b = y<0; 40 | c = a.*b; 41 | 42 | for j=1:size(c,1) 43 | for k=1:size(c,2) 44 | if c(j,k)>0 45 | c(j,k) = NaN; 46 | end 47 | end 48 | end 49 | 50 | z_noPlot = z.*c; 51 | z = z + z_noPlot; 52 | 53 | figure(2) 54 | mesh(x,y,z); 55 | title('THIS IS FOR A VERTICAL ANTENNA') 56 | -------------------------------------------------------------------------------- /dipole/figs/3D_center_fed.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badber/Antenna_pattern_and_design/be98cfa14192e6f031d3732d63270fbba8094733/dipole/figs/3D_center_fed.jpg -------------------------------------------------------------------------------- /dipole/figs/travelin_wave.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badber/Antenna_pattern_and_design/be98cfa14192e6f031d3732d63270fbba8094733/dipole/figs/travelin_wave.jpg -------------------------------------------------------------------------------- /dipole/short_dipole_Vertical.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% Short dipole 4 | 5 | clear all 6 | close all 7 | clc 8 | 9 | Il = 2; 10 | r = 2; 11 | lambda = 2e-3; 12 | 13 | theta = 0:0.01:2*pi; 14 | E_theta = abs(60*pi*Il/(r*lambda)*sin(theta)); 15 | 16 | figure(1) 17 | polar(theta-pi/2,E_theta)% I substract pi/2 from theta so that the pattern corresponds to a vertical antenna instead of a horizontal one 18 | title('E_{\theta} as a function of \theta') 19 | -------------------------------------------------------------------------------- /figs/Radiation_pattern.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badber/Antenna_pattern_and_design/be98cfa14192e6f031d3732d63270fbba8094733/figs/Radiation_pattern.jpg -------------------------------------------------------------------------------- /fourier/README.md: -------------------------------------------------------------------------------- 1 | **Design antenna arrays** to follow a prescribed radation pattern **using a truncated Fourier series** (because any radiation apttern can be expressed as an infinite Fourier series, so truncating it gives an approximation). 2 | 3 | **Example**: design an antenna array whose radiation pattern is between -30° and 30°, and between 150° and 210°. 4 | 5 | Using a 7-element end-fire array: 6 | ![example](figs/7_element.jpg) 7 | 8 | Using a 13-element end-fire array (using more terms in the Fourier series, therefore approximating the prescribed pattern better): 9 | ![example](figs/13_element.jpg) 10 | -------------------------------------------------------------------------------- /fourier/examples/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badber/Antenna_pattern_and_design/be98cfa14192e6f031d3732d63270fbba8094733/fourier/examples/README.md -------------------------------------------------------------------------------- /fourier/examples/fourier1.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | disp('Modify:') 10 | disp('- a0: DC term of the Fourier series') 11 | disp('- a(k): expression for sine coeffs') 12 | disp('- b(k): expression for cosine coeffs') 13 | disp('ALL OF THEM IN THE FIRST SECTION OF THE CODE, "Fourier coeffs"') 14 | disp(' ') 15 | disp('FIRST OF ALL:') 16 | disp('Draw the desired frequency respone (first lines of code)') 17 | disp(' ') 18 | 19 | %% Desired response 20 | x = -pi:0.01:pi; 21 | y = (x>-pi/2).*(x2*pi) || (alpha<-2*pi) 40 | error('Insert a value for alpha between -2\pi and 2\pi.') 41 | end 42 | 43 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 44 | % If given kd, calculate d as d=kd/2*pi. 45 | d = input(prompt); 46 | if ~isscalar(d) 47 | error('Introduce a scalar for the value of "d"') 48 | end 49 | 50 | kd = 2*pi*d; 51 | else 52 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 53 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 54 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 55 | % - If I am given the value of alpha and it is different than 0, it means 56 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 57 | d = input(prompt); 58 | if ~isscalar(d) 59 | error('Introduce a scalar for the value of "d"') 60 | end 61 | 62 | kd = 2*pi*d; 63 | 64 | if strcmp(array_type,'broadside') 65 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 66 | elseif strcmp(array_type,'end_fire') 67 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 68 | end 69 | end 70 | 71 | prompt = sprintf ('What is the number "n" of elements in the array? \n'); 72 | n = input(prompt); 73 | if ~isscalar(n) || (n~=floor(n)) || n<=1 || (((n+1)/2)~=floor(((n+1)/2))) 74 | error('Introduce an odd integer scalar, bigger than 1, for the number of elements in the array (has to be odd because of the Fourier series procedure used)') 75 | end 76 | disp(' ') 77 | disp('NOTE:') 78 | disp('This it the total number of elements in the array, but some of them might not be energized.') 79 | 80 | m = (n-1)/2; % m is the number of sine terms in the Fourier series (same as the number of cosine terms) 81 | 82 | %% Fourier coeffs 83 | 84 | a0=1/2; % Insert the value for a0 85 | for k=1:m 86 | a(k) = 1/(k*pi)*sin(k*pi/2); % Insert the expression for a_k 87 | b(k) = 0; % Insert the expression for b_k 88 | end 89 | 90 | %% Radiation pattern as a function of psi 91 | psi = -pi:0.001:pi; 92 | sum_coeff =0; 93 | for k=1:m 94 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*psi)-b(k)*sin(k*psi)); 95 | end 96 | 97 | E = a0 + sum_coeff; 98 | 99 | figure(1) 100 | plot(psi,E) 101 | 102 | % % Create the polynomial for the electric field E (see back of page 26 of my notes) 103 | % for k=1:m 104 | % A(k) = a(m-k+1)-j*b(m-k+1); 105 | % end 106 | % for k=m+2:2*m+1 107 | % A(k) = a(k-m-1)+j*b(k-m-1); 108 | % end 109 | % A(m+1) = a0; 110 | % 111 | % psi = -pi:0.001:pi; 112 | % z = exp(j*psi); 113 | % E = 0; % Initialize 114 | % for k=1:m 115 | % E = E + A(k)*z.^(k-m-1); 116 | % 117 | % end 118 | % for k=m+2:2*m+1 119 | % E = E + A(k)*z.^(m-k+1); 120 | % end 121 | % E = E + A(m+1); % This is the z^0 term 122 | % 123 | % E = abs(E); 124 | % 125 | % E = 1/pi*(-1/3*z.^(-3)+z.^(-1)+pi/2+z-1/3*z.^3); 126 | 127 | %% Radiation pattern as a function of phi 128 | clear E 129 | 130 | phi = 0:0.001:2*pi; 131 | %psi = (kd*cos(phi)+alpha) 132 | sum_coeff =0; 133 | for k=1:m 134 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*(kd*cos(phi)+alpha))-b(k)*sin(k*(kd*cos(phi)+alpha))); 135 | end 136 | 137 | E = a0 + sum_coeff; 138 | E = abs(E); 139 | 140 | figure(2) 141 | polar(phi,E) 142 | -------------------------------------------------------------------------------- /fourier/examples/fourier2.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | disp('Modify:') 10 | disp('- a0: DC term of the Fourier series') 11 | disp('- a(k): expression for sine coeffs') 12 | disp('- b(k): expression for cosine coeffs') 13 | disp('ALL OF THEM IN THE FIRST SECTION OF THE CODE, "Fourier coeffs"') 14 | disp(' ') 15 | disp('FIRST OF ALL:') 16 | disp('Draw the desired frequency respone (first lines of code)') 17 | disp(' ') 18 | 19 | %% Desired response 20 | x = -pi:0.01:pi; 21 | y = (x>-pi/4).*(x3*pi/4); 23 | figure(1) 24 | plot(x,y) 25 | ylabel('|E|','fontsize',15) 26 | xlabel('\psi','fontsize',15) 27 | grid on 28 | hold on 29 | 30 | %% Array characteristics 31 | prompt = sprintf ('Type: broadside, end-fire array or non? \n(answer "broadside", "end_fire" or "none", as a string in MATLAB) \n'); 32 | array_type = input(prompt); 33 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') && ~strcmp(array_type,'none') 34 | error('Wrong type of array introduced.') 35 | end 36 | 37 | if strcmp(array_type,'none') 38 | prompt = sprintf ('Insert the value of alpha. \n'); 39 | alpha = input(prompt); 40 | if ~isscalar(alpha) || (alpha>2*pi) || (alpha<-2*pi) 41 | error('Insert a value for alpha between -2\pi and 2\pi.') 42 | end 43 | 44 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 45 | % If given kd, calculate d as d=kd/2*pi. 46 | d = input(prompt); 47 | if ~isscalar(d) 48 | error('Introduce a scalar for the value of "d"') 49 | end 50 | 51 | kd = 2*pi*d; 52 | else 53 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 54 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 55 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 56 | % - If I am given the value of alpha and it is different than 0, it means 57 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 58 | d = input(prompt); 59 | if ~isscalar(d) 60 | error('Introduce a scalar for the value of "d"') 61 | end 62 | 63 | kd = 2*pi*d; 64 | 65 | if strcmp(array_type,'broadside') 66 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 67 | elseif strcmp(array_type,'end_fire') 68 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 69 | end 70 | end 71 | 72 | prompt = sprintf ('What is the number "n" of elements in the array? \n'); 73 | n = input(prompt); 74 | if ~isscalar(n) || (n~=floor(n)) || n<=1 || (((n+1)/2)~=floor(((n+1)/2))) 75 | error('Introduce an odd integer scalar, bigger than 1, for the number of elements in the array (has to be odd because of the Fourier series procedure used)') 76 | end 77 | disp(' ') 78 | disp('NOTE:') 79 | disp('This it the total number of elements in the array, but some of them might not be energized.') 80 | 81 | m = (n-1)/2; % m is the number of sine terms in the Fourier series (same as the number of cosine terms) 82 | 83 | %% Fourier coeffs 84 | 85 | a0=0; % Insert the value for a0 86 | for k=1:m 87 | a(k) = 1/(k*pi)*(sin(k*pi/4)+sin(3*pi/4*k)); % Insert the expression for a_k 88 | b(k) = 0; % Insert the expression for b_k 89 | end 90 | 91 | %% Radiation pattern as a function of psi 92 | psi = -pi:0.001:pi; 93 | sum_coeff =0; 94 | for k=1:m 95 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*psi)-b(k)*sin(k*psi)); 96 | end 97 | 98 | E = a0 + sum_coeff; 99 | 100 | figure(1) 101 | plot(psi,E) 102 | 103 | % % Create the polynomial for the electric field E (see back of page 26 of my notes) 104 | % for k=1:m 105 | % A(k) = a(m-k+1)-j*b(m-k+1); 106 | % end 107 | % for k=m+2:2*m+1 108 | % A(k) = a(k-m-1)+j*b(k-m-1); 109 | % end 110 | % A(m+1) = a0; 111 | % 112 | % psi = -pi:0.001:pi; 113 | % z = exp(j*psi); 114 | % E = 0; % Initialize 115 | % for k=1:m 116 | % E = E + A(k)*z.^(k-m-1); 117 | % 118 | % end 119 | % for k=m+2:2*m+1 120 | % E = E + A(k)*z.^(m-k+1); 121 | % end 122 | % E = E + A(m+1); % This is the z^0 term 123 | % 124 | % E = abs(E); 125 | % 126 | % E = 1/pi*(-1/3*z.^(-3)+z.^(-1)+pi/2+z-1/3*z.^3); 127 | 128 | %% Radiation pattern as a function of phi 129 | clear E 130 | 131 | phi = 0:0.001:2*pi; 132 | %psi = (kd*cos(phi)+alpha) 133 | sum_coeff =0; 134 | for k=1:m 135 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*(kd*cos(phi)+alpha))-b(k)*sin(k*(kd*cos(phi)+alpha))); 136 | end 137 | 138 | E = a0 + sum_coeff; 139 | E = abs(E); 140 | 141 | figure(2) 142 | polar(phi,E) 143 | -------------------------------------------------------------------------------- /fourier/examples/fourier3.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | disp('Modify:') 10 | disp('- a0: DC term of the Fourier series') 11 | disp('- a(k): expression for sine coeffs') 12 | disp('- b(k): expression for cosine coeffs') 13 | disp('ALL OF THEM IN THE FIRST SECTION OF THE CODE, "Fourier coeffs"') 14 | disp(' ') 15 | disp('FIRST OF ALL:') 16 | disp('Draw the desired frequency respone (first lines of code)') 17 | disp(' ') 18 | 19 | %% Desired response 20 | x = -pi:0.01:pi; 21 | y = (x>-0.4209).*(x<0.4209); 22 | figure(1) 23 | plot(x,y) 24 | ylabel('|E|','fontsize',15) 25 | xlabel('\psi','fontsize',15) 26 | grid on 27 | hold on 28 | 29 | %% Array characteristics 30 | prompt = sprintf ('Type: broadside, end-fire array or non? \n(answer "broadside", "end_fire" or "none", as a string in MATLAB) \n'); 31 | array_type = input(prompt); 32 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') && ~strcmp(array_type,'none') 33 | error('Wrong type of array introduced.') 34 | end 35 | 36 | if strcmp(array_type,'none') 37 | prompt = sprintf ('Insert the value of alpha. \n'); 38 | alpha = input(prompt); 39 | if ~isscalar(alpha) || (alpha>2*pi) || (alpha<-2*pi) 40 | error('Insert a value for alpha between -2\pi and 2\pi.') 41 | end 42 | 43 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 44 | % If given kd, calculate d as d=kd/2*pi. 45 | d = input(prompt); 46 | if ~isscalar(d) 47 | error('Introduce a scalar for the value of "d"') 48 | end 49 | 50 | kd = 2*pi*d; 51 | else 52 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 53 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 54 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 55 | % - If I am given the value of alpha and it is different than 0, it means 56 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 57 | d = input(prompt); 58 | if ~isscalar(d) 59 | error('Introduce a scalar for the value of "d"') 60 | end 61 | 62 | kd = 2*pi*d; 63 | 64 | if strcmp(array_type,'broadside') 65 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 66 | elseif strcmp(array_type,'end_fire') 67 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 68 | end 69 | end 70 | 71 | prompt = sprintf ('What is the number "n" of elements in the array? \n'); 72 | n = input(prompt); 73 | if ~isscalar(n) || (n~=floor(n)) || n<=1 || (((n+1)/2)~=floor(((n+1)/2))) 74 | error('Introduce an odd integer scalar, bigger than 1, for the number of elements in the array (has to be odd because of the Fourier series procedure used)') 75 | end 76 | disp(' ') 77 | disp('NOTE:') 78 | disp('This it the total number of elements in the array, but some of them might not be energized.') 79 | 80 | m = (n-1)/2; % m is the number of sine terms in the Fourier series (same as the number of cosine terms) 81 | 82 | %% Fourier coeffs 83 | 84 | a0=1/6; % Insert the value for a0 85 | for k=1:m 86 | a(k) = 1/(k*pi)*sin(k*pi/6); % Insert the expression for a_k 87 | b(k) = 0; % Insert the expression for b_k 88 | end 89 | 90 | %% Radiation pattern as a function of psi 91 | psi = -pi:0.001:pi; 92 | sum_coeff =0; 93 | for k=1:m 94 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*psi)-b(k)*sin(k*psi)); 95 | end 96 | 97 | E = a0 + sum_coeff; 98 | 99 | figure(1) 100 | plot(psi,E) 101 | 102 | % % Create the polynomial for the electric field E (see back of page 26 of my notes) 103 | % for k=1:m 104 | % A(k) = a(m-k+1)-j*b(m-k+1); 105 | % end 106 | % for k=m+2:2*m+1 107 | % A(k) = a(k-m-1)+j*b(k-m-1); 108 | % end 109 | % A(m+1) = a0; 110 | % 111 | % psi = -pi:0.001:pi; 112 | % z = exp(j*psi); 113 | % E = 0; % Initialize 114 | % for k=1:m 115 | % E = E + A(k)*z.^(k-m-1); 116 | % 117 | % end 118 | % for k=m+2:2*m+1 119 | % E = E + A(k)*z.^(m-k+1); 120 | % end 121 | % E = E + A(m+1); % This is the z^0 term 122 | % 123 | % E = abs(E); 124 | % 125 | % E = 1/pi*(-1/3*z.^(-3)+z.^(-1)+pi/2+z-1/3*z.^3); 126 | 127 | %% Radiation pattern as a function of phi 128 | clear E 129 | 130 | phi = 0:0.001:2*pi; 131 | %psi = (kd*cos(phi)+alpha) 132 | sum_coeff =0; 133 | for k=1:m 134 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*(kd*cos(phi)+alpha))-b(k)*sin(k*(kd*cos(phi)+alpha))); 135 | end 136 | 137 | E = a0 + sum_coeff; 138 | E = abs(E); 139 | 140 | figure(2) 141 | polar(phi,E) 142 | -------------------------------------------------------------------------------- /fourier/examples/fourier4.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | disp('Modify:') 10 | disp('- a0: DC term of the Fourier series') 11 | disp('- a(k): expression for sine coeffs') 12 | disp('- b(k): expression for cosine coeffs') 13 | disp('ALL OF THEM IN THE FIRST SECTION OF THE CODE, "Fourier coeffs"') 14 | disp(' ') 15 | disp('FIRST OF ALL:') 16 | disp('Draw the desired frequency respone (first lines of code)') 17 | disp(' ') 18 | 19 | %% Desired response 20 | x = -pi:0.01:pi; 21 | y = (x>-1.0745).*(x<1.0745); 22 | figure(1) 23 | plot(x,y) 24 | ylabel('|E|','fontsize',15) 25 | xlabel('\psi','fontsize',15) 26 | grid on 27 | hold on 28 | 29 | %% Array characteristics 30 | prompt = sprintf ('Type: broadside, end-fire array or non? \n(answer "broadside", "end_fire" or "none", as a string in MATLAB) \n'); 31 | array_type = input(prompt); 32 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') && ~strcmp(array_type,'none') 33 | error('Wrong type of array introduced.') 34 | end 35 | 36 | if strcmp(array_type,'none') 37 | prompt = sprintf ('Insert the value of alpha. \n'); 38 | alpha = input(prompt); 39 | if ~isscalar(alpha) || (alpha>2*pi) || (alpha<-2*pi) 40 | error('Insert a value for alpha between -2\pi and 2\pi.') 41 | end 42 | 43 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 44 | % If given kd, calculate d as d=kd/2*pi. 45 | d = input(prompt); 46 | if ~isscalar(d) 47 | error('Introduce a scalar for the value of "d"') 48 | end 49 | 50 | kd = 2*pi*d; 51 | else 52 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 53 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 54 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 55 | % - If I am given the value of alpha and it is different than 0, it means 56 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 57 | d = input(prompt); 58 | if ~isscalar(d) 59 | error('Introduce a scalar for the value of "d"') 60 | end 61 | 62 | kd = 2*pi*d; 63 | 64 | if strcmp(array_type,'broadside') 65 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 66 | elseif strcmp(array_type,'end_fire') 67 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 68 | end 69 | end 70 | 71 | prompt = sprintf ('What is the number "n" of elements in the array? \n'); 72 | n = input(prompt); 73 | if ~isscalar(n) || (n~=floor(n)) || n<=1 || (((n+1)/2)~=floor(((n+1)/2))) 74 | error('Introduce an odd integer scalar, bigger than 1, for the number of elements in the array (has to be odd because of the Fourier series procedure used)') 75 | end 76 | disp(' ') 77 | disp('NOTE:') 78 | disp('This it the total number of elements in the array, but some of them might not be energized.') 79 | 80 | m = (n-1)/2; % m is the number of sine terms in the Fourier series (same as the number of cosine terms) 81 | 82 | %% Fourier coeffs 83 | 84 | a0=0.3420; % Insert the value for a0 85 | for k=1:m 86 | a(k) = 1/(k*pi)*sin(k*1.0745); % Insert the expression for a_k 87 | b(k) = 0; % Insert the expression for b_k 88 | end 89 | 90 | %% Radiation pattern as a function of psi 91 | psi = -pi:0.001:pi; 92 | sum_coeff =0; 93 | for k=1:m 94 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*psi)-b(k)*sin(k*psi)); 95 | end 96 | 97 | E = a0 + sum_coeff; 98 | 99 | figure(1) 100 | plot(psi,E) 101 | 102 | % % Create the polynomial for the electric field E (see back of page 26 of my notes) 103 | % for k=1:m 104 | % A(k) = a(m-k+1)-j*b(m-k+1); 105 | % end 106 | % for k=m+2:2*m+1 107 | % A(k) = a(k-m-1)+j*b(k-m-1); 108 | % end 109 | % A(m+1) = a0; 110 | % 111 | % psi = -pi:0.001:pi; 112 | % z = exp(j*psi); 113 | % E = 0; % Initialize 114 | % for k=1:m 115 | % E = E + A(k)*z.^(k-m-1); 116 | % 117 | % end 118 | % for k=m+2:2*m+1 119 | % E = E + A(k)*z.^(m-k+1); 120 | % end 121 | % E = E + A(m+1); % This is the z^0 term 122 | % 123 | % E = abs(E); 124 | % 125 | % E = 1/pi*(-1/3*z.^(-3)+z.^(-1)+pi/2+z-1/3*z.^3); 126 | 127 | %% Radiation pattern as a function of phi 128 | clear E 129 | 130 | phi = 0:0.001:2*pi; 131 | %psi = (kd*cos(phi)+alpha) 132 | sum_coeff =0; 133 | for k=1:m 134 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*(kd*cos(phi)+alpha))-b(k)*sin(k*(kd*cos(phi)+alpha))); 135 | end 136 | 137 | E = a0 + sum_coeff; 138 | E = abs(E); 139 | 140 | figure(2) 141 | polar(phi,E) 142 | -------------------------------------------------------------------------------- /fourier/figs/13_element.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badber/Antenna_pattern_and_design/be98cfa14192e6f031d3732d63270fbba8094733/fourier/figs/13_element.jpg -------------------------------------------------------------------------------- /fourier/figs/7_element.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badber/Antenna_pattern_and_design/be98cfa14192e6f031d3732d63270fbba8094733/fourier/figs/7_element.jpg -------------------------------------------------------------------------------- /fourier/fourier.m: -------------------------------------------------------------------------------- 1 | % Author: Luis Badesa 2 | 3 | %% 4 | clear all 5 | close all 6 | clc 7 | 8 | %% 9 | disp('Modify:') 10 | disp('- a0: DC term of the Fourier series') 11 | disp('- a(k): expression for sine coeffs') 12 | disp('- b(k): expression for cosine coeffs') 13 | disp('ALL OF THEM IN THE FIRST SECTION OF THE CODE, "Fourier coeffs"') 14 | disp(' ') 15 | disp('FIRST OF ALL:') 16 | disp('Draw the desired frequency respone (first lines of code)') 17 | disp(' ') 18 | 19 | %% Desired response 20 | x = -pi:0.01:pi; 21 | y = (x>-1.0745).*(x<1.0745); 22 | figure(1) 23 | plot(x,y) 24 | ylabel('|E|','fontsize',15) 25 | xlabel('\psi','fontsize',15) 26 | grid on 27 | hold on 28 | 29 | %% Array characteristics 30 | prompt = sprintf ('Type: broadside, end-fire array or none? \n(answer "broadside", "end_fire" or "none", as a string in MATLAB) \n'); 31 | array_type = input(prompt); 32 | if ~strcmp(array_type,'broadside') && ~strcmp(array_type,'end_fire') && ~strcmp(array_type,'none') 33 | error('Wrong type of array introduced.') 34 | end 35 | 36 | if strcmp(array_type,'none') 37 | prompt = sprintf ('Insert the value of alpha. \n'); 38 | alpha = input(prompt); 39 | if ~isscalar(alpha) || (alpha>2*pi) || (alpha<-2*pi) 40 | error('Insert a value for alpha between -2\pi and 2\pi.') 41 | end 42 | 43 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 44 | % If given kd, calculate d as d=kd/2*pi. 45 | d = input(prompt); 46 | if ~isscalar(d) 47 | error('Introduce a scalar for the value of "d"') 48 | end 49 | 50 | kd = 2*pi*d; 51 | else 52 | prompt = sprintf ('What is the value of "d", separation between \neach antenna and the following one in the array? \n(insert a number in terms of lambda, \nEx: introducing 1/2 means d=lambda/2) \n'); 53 | % If given kd or alpha, do this (see notes of lecture 18, page 4): 54 | % - If I am given the value of kd, calculate d as d=kd/2*pi. 55 | % - If I am given the value of alpha and it is different than 0, it means 56 | % that it is an end_fire array, then alpha=kd and d = alpha/2*pi. 57 | d = input(prompt); 58 | if ~isscalar(d) 59 | error('Introduce a scalar for the value of "d"') 60 | end 61 | 62 | kd = 2*pi*d; 63 | 64 | if strcmp(array_type,'broadside') 65 | alpha = 0; % Because alpha = 0 for broadside (Lecture 18 notes, page 1) 66 | elseif strcmp(array_type,'end_fire') 67 | alpha = -kd; % Because alpha = -kd for end-fire (Lecture 18 notes, page 1) 68 | end 69 | end 70 | 71 | prompt = sprintf ('What is the number "n" of elements in the array? \n'); 72 | n = input(prompt); 73 | if ~isscalar(n) || (n~=floor(n)) || n<=1 || (((n+1)/2)~=floor(((n+1)/2))) 74 | error('Introduce an odd integer scalar, bigger than 1, for the number of elements in the array (has to be odd because of the Fourier series procedure used)') 75 | end 76 | disp(' ') 77 | disp('NOTE:') 78 | disp('This it the total number of elements in the array, but some of them might not be energized.') 79 | 80 | m = (n-1)/2; % m is the number of sine terms in the Fourier series (same as the number of cosine terms) 81 | 82 | %% Fourier coeffs 83 | 84 | a0=0.3420; % Insert the value for a0 85 | for k=1:m 86 | a(k) = 1/(k*pi)*sin(k*1.0745); % Insert the expression for a_k 87 | b(k) = 0; % Insert the expression for b_k 88 | end 89 | 90 | %% Radiation pattern as a function of psi 91 | psi = -pi:0.001:pi; 92 | sum_coeff =0; 93 | for k=1:m 94 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*psi)-b(k)*sin(k*psi)); 95 | end 96 | 97 | E = a0 + sum_coeff; 98 | 99 | figure(1) 100 | plot(psi,E) 101 | 102 | % % Create the polynomial for the electric field E (see back of page 26 of my notes) 103 | % for k=1:m 104 | % A(k) = a(m-k+1)-j*b(m-k+1); 105 | % end 106 | % for k=m+2:2*m+1 107 | % A(k) = a(k-m-1)+j*b(k-m-1); 108 | % end 109 | % A(m+1) = a0; 110 | % 111 | % psi = -pi:0.001:pi; 112 | % z = exp(j*psi); 113 | % E = 0; % Initialize 114 | % for k=1:m 115 | % E = E + A(k)*z.^(k-m-1); 116 | % 117 | % end 118 | % for k=m+2:2*m+1 119 | % E = E + A(k)*z.^(m-k+1); 120 | % end 121 | % E = E + A(m+1); % This is the z^0 term 122 | % 123 | % E = abs(E); 124 | % 125 | % E = 1/pi*(-1/3*z.^(-3)+z.^(-1)+pi/2+z-1/3*z.^3); 126 | 127 | %% Radiation pattern as a function of phi 128 | clear E 129 | 130 | phi = 0:0.001:2*pi; 131 | %psi = (kd*cos(phi)+alpha) 132 | sum_coeff =0; 133 | for k=1:m 134 | sum_coeff = sum_coeff + 2*(a(k)*cos(k*(kd*cos(phi)+alpha))-b(k)*sin(k*(kd*cos(phi)+alpha))); 135 | end 136 | 137 | E = a0 + sum_coeff; 138 | E = abs(E); 139 | 140 | figure(2) 141 | polar(phi,E) 142 | --------------------------------------------------------------------------------