Antenna array pattern in 3D space
Show older comments
Hy guys. Can please someone help me. When I start the program I have an error: Error: Unexpected MATLAB operator.
%Tadej Trinko; three-dimensional antenna array pattern
%email:tadej.trinko@gmail.com
%Jožef Štefan International Postgraduate School (MPS IJS), Ljubljana,
%Slovenia
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);
j = sqrt(-1);
% Magnitude, Phase, X,Y,Z coordinate
for I = 1 : N
Current = I
An(I) = input ('Enter the Magnitude 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 : ') ;
Jp(I) = input ('Enter the Phase of the Current : ') ;
end
Phi=(0:1:360)*pi/180;
Theta=(0:1:180)*pi/180;
[THETA,PHI]=meshgrid(Theta,Phi);
% calculate the array factor
for I=1:N
R=An(I)*exp(1j.*(Ep+Jp(I)));
Ep=B*((Xn(I).*cos(PHI).*sin(THETA))+(Yn(I).*sin(THETA).*sin(PHI))+(Zn(I).*cos(THETA)));
end
%plot the array factor
X=R.*sin(THETA).*cos(PHI);
Y=R.*sin(THETA).*sin(PHI);
Z=R.*cos(THETA);
figure();
mesh(X,Y,Z); %display
surf(X,Y,Z) %colored faces
Equation (1) on page 4 in article: http://www.loe.ee.upatras.gr/EM/Journals/Array%20Factor%20Measurements%20A%20Preliminary%20Stage%20in%20a%20Methodology%20for%20Smart%20Antenna%20Characterization%20Measurements.pdf
Thank you for any advice or comment.
Regards, Tadej
Accepted Answer
More Answers (1)
Walter Roberson
on 30 Aug 2011
1 vote
Which line does it complain about, and which column?:
I am not sure that 1j can be used to mean 1 times the imaginary unit. I know 1i can be used. As you defined j as sqrt(-1) it would seem to be more consistent for you to use 1*j in that location.
Your second "for" loop, the one with the comment "calculate the array factor", does not store its results, and does not use the results in further computation. That is going to cause R and Ep to be overwritten during each iteration of the loop, and so will contain only a single value at the end of the loop.
I would suggest that you want R(I)= ... and Ep(I) = ... but the Ep expression appears to have a vector result, so at the very least it would have to be Ep(I,:) or Ep(:,I). I also see that If you were to use R(I) then R would end up of length N, but R is then .* by trig array values that are 361 x 181 so multiplying by a vector R of length N is problematic.
Your code appears to be incomplete and incorrect.
9 Comments
Walter Roberson
on 30 Aug 2011
Ah, I just noticed your second "for" loop does use Ep in defining R. But it does that before Ep has been defined at all.
Tadej
on 30 Aug 2011
Tadej
on 30 Aug 2011
Walter Roberson
on 30 Aug 2011
Did you try to store this in a file named 3Darray_2.m ? Filenames for scripts have to follow the same rules as filenames for functions, which in turn have to follow the same rules as the names of identifiers: the first character must be an upper or lower case English ('Latin') letter, and the characters after that can be upper or lower case English letters or the English digits 0 through 9 or the character underscore ('_')
Tadej
on 31 Aug 2011
Tadej
on 31 Aug 2011
Walter Roberson
on 31 Aug 2011
Please re-read the "I would suggest that you want" section of my response...
Tadej
on 9 Sep 2011
Tadej
on 9 Sep 2011
Categories
Find more on Array Geometries and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!