I tried this code but it gives me an error
There are 8 antennas placed in a circle and there are two sources in the far field from which rays are coming and are incident on these antennas. The mathematical formula for array factor "AF" is given in the attachment. This derivation of this formula is also attached. Now if the angles of those two sources are 30 and 70 respectively which I assign to a vector u. Then I want to put these angles one by one while spanning all the 8 antennas. I mean when I put angle 30 in the formula, then the AF should be calculated over all the 8 antennas. Likewise then put the 2nd angle 70 in the formula and calculate the AF over all the 8 antennas. So when I check the AF, it should be an 8 x 2 matrix where 8 are antennas and 2 are angles. I have tried for its code as below but it gives me an error:
clear;clc
f=1e9;% frequency
c=3e8;% speed of light
l=c/f;% lambda
k=(2*pi)/l;% wavenumber
N=8;% Number of antennas
n=0:N-1;
phi_n=2*pi*n/N;
u=[30 70];% The two Angles
M=length(u);% Number of angles
d_circular=l/2;% spacing b/w elements
circumference = N*d_circular;
a = circumference/2*pi; % Radius
for sourceNo=1:M
for m=0:N-1
% AF = sgma from n=0 to N-1 (exp(-1j*k*a*cos(phi-phin))
AF(m)=sum(exp(-1i*k*a*(cos(u(sourceNo)-phi_n))));
end
end
AFThere are 8 antennas placed in a circle and there are two sources in the far field from which rays are coming and are incident on these antennas. The mathematical formula for array factor "AF" is given in the attachment. This derivation of this formula is also attached. Now if the angles of those two sources are 30 and 70 respectively which I assign to a vector u. Then I want to put these angles one by one while spanning all the 8 antennas. I mean when I put angle 30 in the formula, then the AF should be calculated over all the 8 antennas. Likewise then put the 2nd angle 70 in the formula and calculate the AF over all the 8 antennas. So when I check the AF, it should be an 8 x 2 matrix where 8 are antennas and 2 are angles. I have tried for its code as below but it gives me an error:
clear;clc
f=1e9;% frequency
c=3e8;% speed of light
l=c/f;% lambda
k=(2*pi)/l;% wavenumber
N=8;% Number of antennas
n=0:N-1;
phi_n=2*pi*n/N;
u=[30 70];% The two Angles
M=length(u);% Number of angles
d_circular=l/2;% spacing b/w elements
circumference = N*d_circular;
a = circumference/2*pi; % Radius
for sourceNo=1:M
for m=0:N-1
% AF = sgma from n=0 to N-1 (exp(-1j*k*a*cos(phi-phin))
AF(m)=sum(exp(-1i*k*a*(cos(u(sourceNo)-phi_n))));
end
end
AF There are 8 antennas placed in a circle and there are two sources in the far field from which rays are coming and are incident on these antennas. The mathematical formula for array factor "AF" is given in the attachment. This derivation of this formula is also attached. Now if the angles of those two sources are 30 and 70 respectively which I assign to a vector u. Then I want to put these angles one by one while spanning all the 8 antennas. I mean when I put angle 30 in the formula, then the AF should be calculated over all the 8 antennas. Likewise then put the 2nd angle 70 in the formula and calculate the AF over all the 8 antennas. So when I check the AF, it should be an 8 x 2 matrix where 8 are antennas and 2 are angles. I have tried for its code as below but it gives me an error:
clear;clc
f=1e9;% frequency
c=3e8;% speed of light
l=c/f;% lambda
k=(2*pi)/l;% wavenumber
N=8;% Number of antennas
n=0:N-1;
phi_n=2*pi*n/N;
u=[30 70];% The two Angles
M=length(u);% Number of angles
d_circular=l/2;% spacing b/w elements
circumference = N*d_circular;
a = circumference/2*pi; % Radius
for sourceNo=1:M
for m=0:N-1
% AF = sgma from n=0 to N-1 (exp(-1j*k*a*cos(phi-phin))
AF(m)=sum(exp(-1i*k*a*(cos(u(sourceNo)-phi_n))));
end
end
AF code gives an error, how to modify MATLAB Answers — New Questions