Thread Subject: Error :"In an assignment A(I) = B, the number of elements in B and I must be the same."
Show older comments
I have a problem with calculating Ep(I). Any suggestion how to sole this problem?
clear all;
% element numbers N, wavenumber B
N = input ('Enter the Number of Array Elements : ') ;
lambda = input ('Enter the Value of Lambda (c/f) : ') ;
B =(2*pi/lambda);
% Magnitude, Phase, X,Y,Z coordinate
for I = 1 : N
Current = I
An(I) = input ('Enter the Magnitude of the Current : ') ;
Jp(I) = input ('Enter the Phase of the Current : ') ;
Xn(I) = input ('Enter the Position of Element on X-axis : ') ;
Yn(I) = input ('Enter the Position of Element on Y-axis : ') ;
Zn(I) = input ('Enter the Position of Element on Z-axis : ') ;
end
%azimut--> 0<Phi<360, elevation--> 0<Theta<180
Phhi = (0:1:360)*2*pi/180;
Thheta = (0:1:180)*2*pi/180;
[PHI,THETA] = meshgrid(Phhi,Thheta);
%R=[];
% calculate the array factor
for I = 1:N
Ep(I)= B.*((Xn(I).*cos(PHI).*sin(THETA))+(Yn(I).*sin(THETA).*sin(PHI))+(Zn(I).*cos(THETA)));
R(I)= An(I).*exp(1i.*(Ep(I)+(Jp(I).*pi/180)));
end
h(THETA,PHI) = sum(R);
AF(THETA,PHI) = abs(h(THETA,PHI));
%plot the array factor
X = AF.*sin(THETA).*cos(PHI);
Y = AF.*sin(THETA).*sin(PHI);
Z = AF.*cos(THETA);
figure(2);
mesh(X,Y,Z); %display
%surf(X,Y,Z) %colored faces
Best regards, Tadej
2 Comments
Walter Roberson
on 12 Sep 2011
See also this earlier question on the same topic:
http://www.mathworks.com/matlabcentral/answers/14772-antenna-array-pattern-in-3d-space
Tadej
on 12 Sep 2011
Accepted Answer
More Answers (1)
Tadej
on 19 Sep 2011
Categories
Find more on Array Geometries and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!