How to do correction in this piece of code?
clear;clc
u=[30 50 60 80];% [Theta1 Theta2 Phi1 Phi2] four angles
M=length(u);
P=M/2; % No. of sources
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;
phi_n = rad2deg(phi_n);
d_circular=l/2;% spacing b/w antennas
circumference = N*d_circular;
a=circumference/(2*pi);% radius
% AF = sum(exp(-i*k*a*sin(theta(m))*(cos(phi(p)-phi_n))));
% x = abs(AF(m,p))*sin(theta(m))*cos(phi(p));
% y = abs(AF(m,p))*sin(theta(m))*sin(phi(p));
% z = abs(AF(m,p))*cos(theta(m));
% loops method:
for sourceNo=1:P
for m=0:N-1
AF(m+1,sourceNo) = exp(-1i*k*a*sind(u(1:2)-phi_n(m+1)));
x(m+1,sourceNo) = abs (AF(m+1,sourceNo))*sin(u(1:2))*cos(u(3:4));
y(m+1,sourceNo) = abs(AF(m+1,sourceNo))*sin(u(1:2))*sin(u(3:4));
z(m+1,sourceNo) = abs(AF(m+1,sourceNo))*cos(u(1:2));
end
end
AF
x
y
zclear;clc
u=[30 50 60 80];% [Theta1 Theta2 Phi1 Phi2] four angles
M=length(u);
P=M/2; % No. of sources
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;
phi_n = rad2deg(phi_n);
d_circular=l/2;% spacing b/w antennas
circumference = N*d_circular;
a=circumference/(2*pi);% radius
% AF = sum(exp(-i*k*a*sin(theta(m))*(cos(phi(p)-phi_n))));
% x = abs(AF(m,p))*sin(theta(m))*cos(phi(p));
% y = abs(AF(m,p))*sin(theta(m))*sin(phi(p));
% z = abs(AF(m,p))*cos(theta(m));
% loops method:
for sourceNo=1:P
for m=0:N-1
AF(m+1,sourceNo) = exp(-1i*k*a*sind(u(1:2)-phi_n(m+1)));
x(m+1,sourceNo) = abs (AF(m+1,sourceNo))*sin(u(1:2))*cos(u(3:4));
y(m+1,sourceNo) = abs(AF(m+1,sourceNo))*sin(u(1:2))*sin(u(3:4));
z(m+1,sourceNo) = abs(AF(m+1,sourceNo))*cos(u(1:2));
end
end
AF
x
y
z clear;clc
u=[30 50 60 80];% [Theta1 Theta2 Phi1 Phi2] four angles
M=length(u);
P=M/2; % No. of sources
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;
phi_n = rad2deg(phi_n);
d_circular=l/2;% spacing b/w antennas
circumference = N*d_circular;
a=circumference/(2*pi);% radius
% AF = sum(exp(-i*k*a*sin(theta(m))*(cos(phi(p)-phi_n))));
% x = abs(AF(m,p))*sin(theta(m))*cos(phi(p));
% y = abs(AF(m,p))*sin(theta(m))*sin(phi(p));
% z = abs(AF(m,p))*cos(theta(m));
% loops method:
for sourceNo=1:P
for m=0:N-1
AF(m+1,sourceNo) = exp(-1i*k*a*sind(u(1:2)-phi_n(m+1)));
x(m+1,sourceNo) = abs (AF(m+1,sourceNo))*sin(u(1:2))*cos(u(3:4));
y(m+1,sourceNo) = abs(AF(m+1,sourceNo))*sin(u(1:2))*sin(u(3:4));
z(m+1,sourceNo) = abs(AF(m+1,sourceNo))*cos(u(1:2));
end
end
AF
x
y
z how to remove error, error, changes required MATLAB Answers — New Questions